Fix schema for Map/HashMap (use references)
commit7308ebc4d47b581ddf707ca05d9ad76d9bb06f33
authorNickolay Kudasov <nickolay.kudasov@gmail.com>
dateFri 11 Mar 2016, 00:29 (11 years ago)
parentad04ad2
src/Data/Swagger/Internal.hs+1−1
@@ -483,7 +483,7 @@ data Schema = Schema
483483
484484 , _schemaAllOf :: Maybe [Schema]
485485 , _schemaProperties :: HashMap Text (Referenced Schema)
486− , _schemaAdditionalProperties :: Maybe Schema
486+ , _schemaAdditionalProperties :: Maybe (Referenced Schema)
487487
488488 , _schemaDiscriminator :: Maybe Text
489489 , _schemaReadOnly :: Maybe Bool
src/Data/Swagger/Internal/Schema.hs+1−1
@@ -471,7 +471,7 @@ instance ToSchema a => ToSchema (IntMap a) where
471471
472472instance ToSchema a => ToSchema (Map String a) where
473473 declareNamedSchema _ = do
474− schema <- declareSchema (Proxy :: Proxy a)
474+ schema <- declareSchemaRef (Proxy :: Proxy a)
475475 return $ unnamed $ mempty
476476 & type_ .~ SwaggerObject
477477 & additionalProperties ?~ schema
src/Data/Swagger/Internal/Schema/Validation.hs+1−1
@@ -291,7 +291,7 @@ validateObject o = withSchema $ \schema ->
291291 Null | not (k `elem` (schema ^. required)) -> valid -- null is fine for non-required property
292292 _ ->
293293 case HashMap.lookup k (schema ^. properties) of
294− Nothing -> check additionalProperties $ \s -> sub s $ validateWithSchema v
294+ Nothing -> check additionalProperties $ \s -> validateWithSchemaRef s v
295295 Just s -> validateWithSchemaRef s v
296296
297297validateEnum :: Value -> Validation (ParamSchema t) ()
test/Data/SwaggerSpec.hs+1−1
@@ -271,7 +271,7 @@ schemaSimpleModelExampleJSON = [aesonQQ|
271271schemaModelDictExample :: Schema
272272schemaModelDictExample = mempty
273273 & type_ .~ SwaggerObject
274− & additionalProperties ?~ (mempty & type_ .~ SwaggerString)
274+ & additionalProperties ?~ Inline (mempty & type_ .~ SwaggerString)
275275
276276schemaModelDictExampleJSON :: Value
277277schemaModelDictExampleJSON = [aesonQQ|