Skip to content

Commit

Permalink
Merge pull request #120 from rodrigosetti/referenced-allof
Browse files Browse the repository at this point in the history
Allow allOf to accept referenced schemas fix #119
  • Loading branch information
fizruk committed Sep 10, 2017
2 parents 0240208 + 573b816 commit 7e55105
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.1.4.2
-------

* `allOf` accepts reference schema (see [#119](https://github.com/GetShopTV/swagger2/issues/119))

2.1.4.1
-------

Expand Down
2 changes: 1 addition & 1 deletion src/Data/Swagger/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ data Schema = Schema
, _schemaDescription :: Maybe Text
, _schemaRequired :: [ParamName]

, _schemaAllOf :: Maybe [Schema]
, _schemaAllOf :: Maybe [Referenced Schema]
, _schemaProperties :: InsOrdHashMap Text (Referenced Schema)
, _schemaAdditionalProperties :: Maybe (Referenced Schema)

Expand Down
2 changes: 1 addition & 1 deletion swagger2.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: swagger2
version: 2.1.4.1
version: 2.1.4.2
synopsis: Swagger 2.0 data model
description:
This library is inteded to be used for decoding and encoding Swagger 2.0 API
Expand Down
31 changes: 31 additions & 0 deletions test/Data/SwaggerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec = do
describe "Parameters Definition Object" $ paramsDefinitionExample <=> paramsDefinitionExampleJSON
describe "Responses Definition Object" $ responsesDefinitionExample <=> responsesDefinitionExampleJSON
describe "Security Definitions Object" $ securityDefinitionsExample <=> securityDefinitionsExampleJSON
describe "Composition Schema Example" $ compositionSchemaExample <=> compositionSchemaExampleJSON
describe "Swagger Object" $ do
context "Todo Example" $ swaggerExample <=> swaggerExampleJSON
context "PetStore Example" $
Expand Down Expand Up @@ -1614,3 +1615,33 @@ petstoreExampleJSON = [aesonQQ|
}
}
|]

compositionSchemaExample :: Schema
compositionSchemaExample = mempty
& type_ .~ SwaggerObject
& Data.Swagger.allOf ?~ [
Ref (Reference "Other")
, Inline (mempty
& type_ .~ SwaggerObject
& properties .~
[ ("greet", Inline $ mempty
& type_ .~ SwaggerString) ])
]

compositionSchemaExampleJSON :: Value
compositionSchemaExampleJSON = [aesonQQ|
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/Other"
},
{
"type": "object",
"properties": {
"greet": { "type": "string" }
}
}
]
}
|]

0 comments on commit 7e55105

Please sign in to comment.