Description
Consider the following schema:
SCHEMA = {
"allOf": [
{"$ref": "#/definitions/ref"},
{"required": ["foo"]}
],
"properties": {
"foo": {},
},
"definitions": {
"ref": {"maxProperties": 1}
},
"type": "object"
}
If we call jsonschema.validate({}, SCHEMA)
then it will complain that 'foo' is a required property
which is expected. But, if we canonicalise the schema, then $ref
keyword will be placed to the schema's root and will cancel the validation of other keywords as implemented in jsonschema. I can't find the exact place in the spec itself, but there are tests in the JSON Schema suite that ensure that other keywords are ignored.
So, with the canonicalised version of the schema an empty object passes validation:
>>> CANONICALISED = canonicalish(SCHEMA)
>>> jsonschema.validate({}, CANONICALISED)
What would be the best way to solve it? Should we check if there are schemas with $ref
keywords, then keep them inside allOf
and move everything else to the previous level?
P.S. I found the issue via Webpack bootstrap-loader configuration file
schema in the testing catalog