git.iko.soy/typeable/swagger2
on master help sign in
Add Schema object test - Model with Example
commitee185acad0b38c7bba0634d19a1fd31a1521ea4b authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSun 8 Nov 2015, 16:48 (11 years ago) parent677e1be
1 file changed+41
test/Data/SwaggerSpec.hs+41
test/Data/SwaggerSpec.hs+41
@@ -45,6 +45,7 @@ spec = do
4545 context "Primitive Sample" $ schemaPrimitiveExample <~> schemaPrimitiveExampleJSON
4646 context "Simple Model" $ schemaSimpleModelExample <~> schemaSimpleModelExampleJSON
4747 context "Model with Map/Dictionary Properties" $ schemaModelDictExample <~> schemaModelDictExampleJSON
48+ context "Model with Example" $ schemaWithExampleExample <~> schemaWithExampleExampleJSON
4849
4950main :: IO ()
5051main = hspec spec
@@ -293,3 +294,43 @@ schemaModelDictExampleJSON = [aesonQQ|
293294 }
294295}
295296|]
297+
298+schemaWithExampleExample :: SwaggerSchema
299+schemaWithExampleExample = mempty
300+ { swaggerSchemaType = SwaggerSchemaObject
301+ , swaggerSchemaProperties =
302+ [ ("id", mempty
303+ { swaggerSchemaType = SwaggerSchemaInteger
304+ , swaggerSchemaFormat = Just "int64" })
305+ , ("name", mempty
306+ { swaggerSchemaType = SwaggerSchemaString }) ]
307+ , swaggerSchemaRequired = [ "name" ]
308+ , swaggerSchemaExample = Just [aesonQQ|
309+ {
310+ "name": "Puma",
311+ "id": 1
312+ }
313+ |] }
314+
315+schemaWithExampleExampleJSON :: Value
316+schemaWithExampleExampleJSON = [aesonQQ|
317+{
318+ "type": "object",
319+ "properties": {
320+ "id": {
321+ "type": "integer",
322+ "format": "int64"
323+ },
324+ "name": {
325+ "type": "string"
326+ }
327+ },
328+ "required": [
329+ "name"
330+ ],
331+ "example": {
332+ "name": "Puma",
333+ "id": 1
334+ }
335+}
336+|]