@@ -5,9 +5,11 @@ module Data.SwaggerSpec where
6import Data.Aeson
6import Data.Aeson
7import Data.Aeson.QQ
7import Data.Aeson.QQ
8+import Data.HashMap.Strict (HashMap)
8import qualified Data.HashMap.Strict as HashMap
9import qualified Data.HashMap.Strict as HashMap
9import Data.Maybe
10import Data.Maybe
10import qualified Data.Vector as Vector
11import qualified Data.Vector as Vector
12+import Data.Text (Text)
12import Data.Swagger
14import Data.Swagger
@@ -46,6 +48,7 @@ spec = do
46 context "Simple Model" $ schemaSimpleModelExample <~> schemaSimpleModelExampleJSON
48 context "Simple Model" $ schemaSimpleModelExample <~> schemaSimpleModelExampleJSON
47 context "Model with Map/Dictionary Properties" $ schemaModelDictExample <~> schemaModelDictExampleJSON
49 context "Model with Map/Dictionary Properties" $ schemaModelDictExample <~> schemaModelDictExampleJSON
48 context "Model with Example" $ schemaWithExampleExample <~> schemaWithExampleExampleJSON
50 context "Model with Example" $ schemaWithExampleExample <~> schemaWithExampleExampleJSON
51+ describe "Schema Object" $ definitionsExample <~> definitionsExampleJSON
50main :: IO ()
53main :: IO ()
51main = hspec spec
54main = hspec spec
@@ -334,3 +337,56 @@ schemaWithExampleExampleJSON = [aesonQQ|
341+-- =======================================================================
342+-- Definitions object
343+-- =======================================================================
345+definitionsExample :: HashMap Text SwaggerSchema
347+ [ ("Category", mempty
348+ { swaggerSchemaType = SwaggerSchemaObject
349+ , swaggerSchemaProperties =
351+ { swaggerSchemaType = SwaggerSchemaInteger
352+ , swaggerSchemaFormat = Just "int64" })
354+ { swaggerSchemaType = SwaggerSchemaString }) ] })
356+ { swaggerSchemaType = SwaggerSchemaObject
357+ , swaggerSchemaProperties =
359+ { swaggerSchemaType = SwaggerSchemaInteger
360+ , swaggerSchemaFormat = Just "int64" })
362+ { swaggerSchemaType = SwaggerSchemaString }) ] }) ]
364+definitionsExampleJSON :: Value
365+definitionsExampleJSON = [aesonQQ|