Properties not detected by validator when composed with allOf
I ran into this issue when attempting to re-use a definition for properties but give them different descriptions:
{
...
"paths" : {
"/" : {
"post": {
"summary": "broken allOf demo",
"parameters" : [ {
"in" : "body",
"name" : "body",
"schema" : {
"$ref" : "#/definitions/Thing"
}
} ],
"responses": { "200": { "description": "OK" } }
}
}
},
"definitions" : {
"Thing" : {
"required" : [ "foo" ],
"properties" : {
"foo" : {
"allOf": [
{ "description" : "Descriptive description describing foo" },
{ "$ref" : "#/definitions/hex" }
]
}
}
},
"hex" : {
"type" : "string",
"pattern": "^(0x)?[a-fA-F0-9]*$"
}
}
}
When I execute a test against this schema, the validator's swaggerDefinition.definitions
object's entry for Thing
is missing the foo
property and I get the error message: Object instance has properties which are not allowed by the schema: ["foo"]
.
I don't get an error when constructing the schema, the property is just silently ignored.
Comments (6)
-
-
reporter - edited description
-
reporter Yeah, the missing comma was just a typo. I hadn't seen that note in the README, it's probably the same issue – I'll check and confirm.
-
Hi @imthedoctor - as @tvdinh mentioned this looks like a known problem with using
additionalProperties
andallOf
.If you can confirm I'll close the ticket.
Cheers.
-
reporter Hey guys, I confirmed this is the known issue. Thanks for the help, go ahead and close this out!
-
- changed status to closed
Known issue.
- Log in to comment
Hi,
Did you try to add this
as suggested in the project's README.md ?
And assuming the missing "," between "required" : ["foo"] and "properties"... is just a type...