git.iko.soy/typeable/swagger2
on master help sign in
Added an additional variant of the MyRoseTree testcase

Without the fix of #132, the added testcase causes nontermination. With the fix, the tests are all green.

commit437638407f82920caf6bcfc3f9f2b30fd42a3c59 authorAdriaan Middelkoop <amiddelkoop@vwd.com> dateTue 24 Oct 2017, 23:23 (9 years ago) parent4ce7dc9
1 file changed+32
test/Data/Swagger/SchemaSpec.hs+32
test/Data/Swagger/SchemaSpec.hs+32
@@ -80,6 +80,7 @@ spec = do
8080 context "Player (unary record)" $ checkToSchema (Proxy :: Proxy Player) playerSchemaJSON
8181 context "Players (inlining schema)" $ checkToSchema (Proxy :: Proxy Players) playersSchemaJSON
8282 context "MyRoseTree (datatypeNameModifier)" $ checkToSchema (Proxy :: Proxy MyRoseTree) myRoseTreeSchemaJSON
83+ context "MyRoseTree' (datatypeNameModifier)" $ checkToSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
8384 context "Sum types" $ do
8485 context "Status (sum of unary constructors)" $ checkToSchema (Proxy :: Proxy Status) statusSchemaJSON
8586 context "Character (ref and record sum)" $ checkToSchema (Proxy :: Proxy Character) characterSchemaJSON
@@ -95,6 +96,7 @@ spec = do
9596 context "Light" $ checkDefs (Proxy :: Proxy Light) ["Color"]
9697 context "Character" $ checkDefs (Proxy :: Proxy Character) ["Player", "Point"]
9798 context "MyRoseTree" $ checkDefs (Proxy :: Proxy MyRoseTree) ["RoseTree"]
99+ context "MyRoseTree'" $ checkDefs (Proxy :: Proxy MyRoseTree') ["myrosetree'"]
98100 context "[Set (Unit, Maybe Color)]" $ checkDefs (Proxy :: Proxy [Set (Unit, Maybe Color)]) ["Unit", "Color"]
99101 context "ResourceId" $ checkDefs (Proxy :: Proxy ResourceId) []
100102 describe "Inlining Schemas" $ do
@@ -103,6 +105,7 @@ spec = do
103105 context "Character (inlining only Player)" $ checkInlinedSchemas ["Player"] (Proxy :: Proxy Character) characterInlinedPlayerSchemaJSON
104106 context "Light" $ checkInlinedSchema (Proxy :: Proxy Light) lightInlinedSchemaJSON
105107 context "MyRoseTree (inlineNonRecursiveSchemas)" $ checkInlinedRecSchema (Proxy :: Proxy MyRoseTree) myRoseTreeSchemaJSON
108+ context "MyRoseTree' (inlineNonRecursiveSchemas)" $ checkInlinedRecSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
106109 describe "Bounded Enum key mapping" $ do
107110 context "ButtonImages" $ checkToSchema (Proxy :: Proxy ButtonImages) buttonImagesSchemaJSON
108111
@@ -398,6 +401,35 @@ myRoseTreeSchemaJSON = [aesonQQ|
398401}
399402|]
400403
404+data MyRoseTree' = MyRoseTree'
405+ { root' :: String
406+ , trees' :: [MyRoseTree']
407+ } deriving (Generic)
408+
409+instance ToSchema MyRoseTree' where
410+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
411+ { datatypeNameModifier = map toLower }
412+
413+myRoseTreeSchemaJSON' :: Value
414+myRoseTreeSchemaJSON' = [aesonQQ|
415+{
416+ "type": "object",
417+ "properties":
418+ {
419+ "root'": { "type": "string" },
420+ "trees'":
421+ {
422+ "type": "array",
423+ "items":
424+ {
425+ "$ref": "#/definitions/myrosetree'"
426+ }
427+ }
428+ },
429+ "required": ["root'", "trees'"]
430+}
431+|]
432+
401433-- ========================================================================
402434-- Inlined (newtype for inlining schemas)
403435-- ========================================================================