git.iko.soy/typeable/openapi3
on master help sign in
Fix schema for Map/HashMap (use references)
7308ebcNickolay Kudasov
src/Data/Swagger/Internal.hs+1−1
@@ -483,7 +483,7 @@ data Schema = Schema
483
483
484 , _schemaAllOf :: Maybe [Schema]
484 , _schemaAllOf :: Maybe [Schema]
485 , _schemaProperties :: HashMap Text (Referenced Schema)
485 , _schemaProperties :: HashMap Text (Referenced Schema)
486− , _schemaAdditionalProperties :: Maybe Schema
486+ , _schemaAdditionalProperties :: Maybe (Referenced Schema)
487
487
488 , _schemaDiscriminator :: Maybe Text
488 , _schemaDiscriminator :: Maybe Text
489 , _schemaReadOnly :: Maybe Bool
489 , _schemaReadOnly :: Maybe Bool
src/Data/Swagger/Internal/Schema.hs+1−1
@@ -471,7 +471,7 @@ instance ToSchema a => ToSchema (IntMap a) where
471
471
472instance ToSchema a => ToSchema (Map String a) where
472instance ToSchema a => ToSchema (Map String a) where
473 declareNamedSchema _ = do
473 declareNamedSchema _ = do
474− schema <- declareSchema (Proxy :: Proxy a)
474+ schema <- declareSchemaRef (Proxy :: Proxy a)
475 return $ unnamed $ mempty
475 return $ unnamed $ mempty
476 & type_ .~ SwaggerObject
476 & type_ .~ SwaggerObject
477 & additionalProperties ?~ schema
477 & additionalProperties ?~ schema
src/Data/Swagger/Internal/Schema/Validation.hs+1−1
@@ -291,7 +291,7 @@ validateObject o = withSchema $ \schema ->
291 Null | not (k `elem` (schema ^. required)) -> valid -- null is fine for non-required property
291 Null | not (k `elem` (schema ^. required)) -> valid -- null is fine for non-required property
292 _ ->
292 _ ->
293 case HashMap.lookup k (schema ^. properties) of
293 case HashMap.lookup k (schema ^. properties) of
294− Nothing -> check additionalProperties $ \s -> sub s $ validateWithSchema v
294+ Nothing -> check additionalProperties $ \s -> validateWithSchemaRef s v
295 Just s -> validateWithSchemaRef s v
295 Just s -> validateWithSchemaRef s v
296
296
297validateEnum :: Value -> Validation (ParamSchema t) ()
297validateEnum :: Value -> Validation (ParamSchema t) ()
test/Data/SwaggerSpec.hs+1−1
@@ -271,7 +271,7 @@ schemaSimpleModelExampleJSON = [aesonQQ|
271schemaModelDictExample :: Schema
271schemaModelDictExample :: Schema
272schemaModelDictExample = mempty
272schemaModelDictExample = mempty
273 & type_ .~ SwaggerObject
273 & type_ .~ SwaggerObject
274− & additionalProperties ?~ (mempty & type_ .~ SwaggerString)
274+ & additionalProperties ?~ Inline (mempty & type_ .~ SwaggerString)
275
275
276schemaModelDictExampleJSON :: Value
276schemaModelDictExampleJSON :: Value
277schemaModelDictExampleJSON = [aesonQQ|
277schemaModelDictExampleJSON = [aesonQQ|