git.iko.soy/typeable/swagger2
on master help sign in
Add test for a unary record with Maybe field (see #142)
commit655885a7e8cad9683d639f61db82e9a5675c24ee authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateWed 7 Mar 2018, 05:34 (9 years ago) parentc669a64
1 file changed+22
test/Data/Swagger/SchemaSpec.hs+22
test/Data/Swagger/SchemaSpec.hs+22
@@ -78,6 +78,7 @@ spec = do
7878 context "Email (unwrapUnaryRecords)" $ checkToSchema (Proxy :: Proxy Email) emailSchemaJSON
7979 context "UserId (non-record newtype)" $ checkToSchema (Proxy :: Proxy UserId) userIdSchemaJSON
8080 context "Player (unary record)" $ checkToSchema (Proxy :: Proxy Player) playerSchemaJSON
81+ context "SingleMaybeField (unary record with Maybe)" $ checkToSchema (Proxy :: Proxy SingleMaybeField) singleMaybeFieldSchemaJSON
8182 context "Players (inlining schema)" $ checkToSchema (Proxy :: Proxy Players) playersSchemaJSON
8283 context "MyRoseTree (datatypeNameModifier)" $ checkToSchema (Proxy :: Proxy MyRoseTree) myRoseTreeSchemaJSON
8384 context "MyRoseTree' (datatypeNameModifier)" $ checkToSchema (Proxy :: Proxy MyRoseTree') myRoseTreeSchemaJSON'
@@ -722,3 +723,24 @@ buttonImagesSchemaJSON = [aesonQQ|
722723}
723724|]
724725
726+
727+-- ========================================================================
728+-- SingleMaybeField (single field data with optional field)
729+-- ========================================================================
730+
731+data SingleMaybeField = SingleMaybeField { singleMaybeField :: Maybe String }
732+ deriving (Show, Generic)
733+
734+instance ToJSON SingleMaybeField
735+instance ToSchema SingleMaybeField
736+
737+singleMaybeFieldSchemaJSON :: Value
738+singleMaybeFieldSchemaJSON = [aesonQQ|
739+{
740+ "type": "object",
741+ "properties":
742+ {
743+ "singleMaybeField": { "type": "string" }
744+ }
745+}
746+|]