git.iko.soy/typeable/openapi3
on master help sign in
Add test with paramSchemaToNamedSchema
a6adc7eNickolay Kudasov
test/Data/Swagger/SchemaSpec.hs+18
@@ -33,6 +33,7 @@ spec = do
33 context "ISPair" $ checkToSchema (Proxy :: Proxy ISPair) ispairSchemaJSON
33 context "ISPair" $ checkToSchema (Proxy :: Proxy ISPair) ispairSchemaJSON
34 context "Point (fieldLabelModifier)" $ checkToSchema (Proxy :: Proxy Point) pointSchemaJSON
34 context "Point (fieldLabelModifier)" $ checkToSchema (Proxy :: Proxy Point) pointSchemaJSON
35 context "Color (bounded enum)" $ checkToSchema (Proxy :: Proxy Color) colorSchemaJSON
35 context "Color (bounded enum)" $ checkToSchema (Proxy :: Proxy Color) colorSchemaJSON
36+ context "Shade (paramSchemaToNamedSchema)" $ checkToSchema (Proxy :: Proxy Shade) shadeSchemaJSON
36 context "Paint (record with bounded enum field)" $ checkToSchema (Proxy :: Proxy Paint) paintSchemaJSON
37 context "Paint (record with bounded enum field)" $ checkToSchema (Proxy :: Proxy Paint) paintSchemaJSON
37 context "UserGroup (set newtype)" $ checkToSchema (Proxy :: Proxy UserGroup) userGroupSchemaJSON
38 context "UserGroup (set newtype)" $ checkToSchema (Proxy :: Proxy UserGroup) userGroupSchemaJSON
38 context "Unary records" $ do
39 context "Unary records" $ do
@@ -49,6 +50,7 @@ spec = do
49 context "String" $ checkSchemaName Nothing (Proxy :: Proxy String)
50 context "String" $ checkSchemaName Nothing (Proxy :: Proxy String)
50 context "(Int, Float)" $ checkSchemaName Nothing (Proxy :: Proxy (Int, Float))
51 context "(Int, Float)" $ checkSchemaName Nothing (Proxy :: Proxy (Int, Float))
51 context "Person" $ checkSchemaName (Just "Person") (Proxy :: Proxy Person)
52 context "Person" $ checkSchemaName (Just "Person") (Proxy :: Proxy Person)
53+ context "Shade" $ checkSchemaName (Just "Shade") (Proxy :: Proxy Shade)
52
54
53main :: IO ()
55main :: IO ()
54main = hspec spec
56main = hspec spec
@@ -137,6 +139,22 @@ colorSchemaJSON = [aesonQQ|
137}
139}
138|]
140|]
139
141
142+-- ========================================================================
143+-- Shade (paramSchemaToNamedSchema)
144+-- ========================================================================
145+
146+data Shade = Dim | Bright deriving (Generic, ToParamSchema)
147+
148+instance ToSchema Shade where toNamedSchema = paramSchemaToNamedSchema defaultSchemaOptions
149+
150+shadeSchemaJSON :: Value
151+shadeSchemaJSON = [aesonQQ|
152+{
153+ "type": "string",
154+ "enum": ["Dim", "Bright"]
155+}
156+|]
157+
140-- ========================================================================
158-- ========================================================================
141-- Paint (record with bounded enum property)
159-- Paint (record with bounded enum property)
142-- ========================================================================
160-- ========================================================================