git.iko.soy/typeable/swagger2
on master help sign in
Add Definitions object test
commitcc208a58f0616679cb22d24bc3f1a2d796824b1d authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSun 8 Nov 2015, 16:56 (11 years ago) parentee185ac
1 file changed+56
test/Data/SwaggerSpec.hs+56
test/Data/SwaggerSpec.hs+56
@@ -5,9 +5,11 @@ module Data.SwaggerSpec where
55
66import Data.Aeson
77import Data.Aeson.QQ
8+import Data.HashMap.Strict (HashMap)
89import qualified Data.HashMap.Strict as HashMap
910import Data.Maybe
1011import qualified Data.Vector as Vector
12+import Data.Text (Text)
1113
1214import Data.Swagger
1315
@@ -46,6 +48,7 @@ spec = do
4648 context "Simple Model" $ schemaSimpleModelExample <~> schemaSimpleModelExampleJSON
4749 context "Model with Map/Dictionary Properties" $ schemaModelDictExample <~> schemaModelDictExampleJSON
4850 context "Model with Example" $ schemaWithExampleExample <~> schemaWithExampleExampleJSON
51+ describe "Schema Object" $ definitionsExample <~> definitionsExampleJSON
4952
5053main :: IO ()
5154main = hspec spec
@@ -334,3 +337,56 @@ schemaWithExampleExampleJSON = [aesonQQ|
334337 }
335338}
336339|]
340+
341+-- =======================================================================
342+-- Definitions object
343+-- =======================================================================
344+
345+definitionsExample :: HashMap Text SwaggerSchema
346+definitionsExample =
347+ [ ("Category", mempty
348+ { swaggerSchemaType = SwaggerSchemaObject
349+ , swaggerSchemaProperties =
350+ [ ("id", mempty
351+ { swaggerSchemaType = SwaggerSchemaInteger
352+ , swaggerSchemaFormat = Just "int64" })
353+ , ("name", mempty
354+ { swaggerSchemaType = SwaggerSchemaString }) ] })
355+ , ("Tag", mempty
356+ { swaggerSchemaType = SwaggerSchemaObject
357+ , swaggerSchemaProperties =
358+ [ ("id", mempty
359+ { swaggerSchemaType = SwaggerSchemaInteger
360+ , swaggerSchemaFormat = Just "int64" })
361+ , ("name", mempty
362+ { swaggerSchemaType = SwaggerSchemaString }) ] }) ]
363+
364+definitionsExampleJSON :: Value
365+definitionsExampleJSON = [aesonQQ|
366+{
367+ "Category": {
368+ "type": "object",
369+ "properties": {
370+ "id": {
371+ "type": "integer",
372+ "format": "int64"
373+ },
374+ "name": {
375+ "type": "string"
376+ }
377+ }
378+ },
379+ "Tag": {
380+ "type": "object",
381+ "properties": {
382+ "id": {
383+ "type": "integer",
384+ "format": "int64"
385+ },
386+ "name": {
387+ "type": "string"
388+ }
389+ }
390+ }
391+}
392+|]