git.iko.soy/typeable/openapi3
on master help sign in
Add Schema object Primitive Sample test
994dad6Nickolay Kudasov
test/Data/SwaggerSpec.hs+52−16
@@ -38,10 +38,12 @@ x <=> json = do
38
38
39spec :: Spec
39spec :: Spec
40spec = do
40spec = do
41− describe "Operation Object" $ operationExample <~> operationExampleJSON
42 describe "License Object" $ licenseExample <=> licenseExampleJSON
41 describe "License Object" $ licenseExample <=> licenseExampleJSON
43 describe "Contact Object" $ contactExample <=> contactExampleJSON
42 describe "Contact Object" $ contactExample <=> contactExampleJSON
44 describe "Info Object" $ infoExample <=> infoExampleJSON
43 describe "Info Object" $ infoExample <=> infoExampleJSON
44+ describe "Operation Object" $ operationExample <~> operationExampleJSON
45+ describe "Schema Object" $ do
46+ context "Primitive Sample" $ schemaPrimitiveExample <~> schemaPrimitiveExampleJSON
45
47
46main :: IO ()
48main :: IO ()
47main = hspec spec
49main = hspec spec
@@ -183,21 +185,6 @@ operationExample = SwaggerOperation
183 , swaggerParameterOtherSchemaCommon = emptySchemaCommon
185 , swaggerParameterOtherSchemaCommon = emptySchemaCommon
184 }
186 }
185
187
186− emptySchemaCommon = SwaggerSchemaCommon
187− { swaggerSchemaDefault = Nothing
188− , swaggerSchemaMaximum = Nothing
189− , swaggerSchemaExclusiveMaximum = Nothing
190− , swaggerSchemaMinimum = Nothing
191− , swaggerSchemaExclusiveMinimum = Nothing
192− , swaggerSchemaMaxLength = Nothing
193− , swaggerSchemaMinLength = Nothing
194− , swaggerSchemaPattern = Nothing
195− , swaggerSchemaMaxItems = Nothing
196− , swaggerSchemaMinItems = Nothing
197− , swaggerSchemaUniqueItems = Nothing
198− , swaggerSchemaEnum = Nothing
199− , swaggerSchemaMultipleOf = Nothing }
200−
201operationExampleJSON :: Value
188operationExampleJSON :: Value
202operationExampleJSON = [aesonQQ|
189operationExampleJSON = [aesonQQ|
203{
190{
@@ -255,3 +242,52 @@ operationExampleJSON = [aesonQQ|
255 ]
242 ]
256}
243}
257|]
244|]
245+
246+-- =======================================================================
247+-- Schema object
248+-- =======================================================================
249+
250+schemaPrimitiveExample :: SwaggerSchema
251+schemaPrimitiveExample = SwaggerSchema
252+ { swaggerSchemaType = SwaggerSchemaString
253+ , swaggerSchemaFormat = Just "email"
254+ , swaggerSchemaTitle = Nothing
255+ , swaggerSchemaDescription = Nothing
256+ , swaggerSchemaRequired = Nothing
257+ , swaggerSchemaItems = Nothing
258+ , swaggerSchemaAllOf = Nothing
259+ , swaggerSchemaProperties = mempty
260+ , swaggerSchemaAdditionalProperties = Nothing
261+ , swaggerSchemaDiscriminator = Nothing
262+ , swaggerSchemaReadOnly = Nothing
263+ , swaggerSchemaXml = Nothing
264+ , swaggerSchemaExternalDocs = Nothing
265+ , swaggerSchemaExample = Nothing
266+ , swaggerSchemaMaxProperties = Nothing
267+ , swaggerSchemaMinProperties = Nothing
268+ , swaggerSchemaCommon = emptySchemaCommon }
269+
270+schemaPrimitiveExampleJSON :: Value
271+schemaPrimitiveExampleJSON = [aesonQQ|
272+{
273+ "type": "string",
274+ "format": "email"
275+}
276+|]
277+
278+emptySchemaCommon :: SwaggerSchemaCommon
279+emptySchemaCommon = SwaggerSchemaCommon
280+ { swaggerSchemaDefault = Nothing
281+ , swaggerSchemaMaximum = Nothing
282+ , swaggerSchemaExclusiveMaximum = Nothing
283+ , swaggerSchemaMinimum = Nothing
284+ , swaggerSchemaExclusiveMinimum = Nothing
285+ , swaggerSchemaMaxLength = Nothing
286+ , swaggerSchemaMinLength = Nothing
287+ , swaggerSchemaPattern = Nothing
288+ , swaggerSchemaMaxItems = Nothing
289+ , swaggerSchemaMinItems = Nothing
290+ , swaggerSchemaUniqueItems = Nothing
291+ , swaggerSchemaEnum = Nothing
292+ , swaggerSchemaMultipleOf = Nothing }
293+