Having this weird issue, not sure if I'm just misunderstanding the usage, or if it's a bug?
It looks like setting additionalProperties to False doesn't understand patternProperties and validation fails?
>>> jsonschema.validate(
... {"a": "a", "b": "a"},
... schema={
... "$schema": "http://json-schema.org/draft-07/schema#",
... "required": ["a"],
... "properties": {
... "a": {"type": "string"},
... "patternProperties": {"b": {"type": "string"}}
... },
... "additionalProperties": False
... }
... )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/venv/lib/python3.9/site-packages/jsonschema/validators.py", line 776, in validate
raise error
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('b' was unexpected)
Failed validating 'additionalProperties' in schema:
{'$schema': 'http://json-schema.org/draft-07/schema#',
'additionalProperties': False,
'properties': {'a': {'type': 'string'},
'patternProperties': {'b': {'type': 'string'}}},
'required': ['a', 'b']}
On instance:
{'a': 'a', 'b': 'a'}
Having this weird issue, not sure if I'm just misunderstanding the usage, or if it's a bug?
It looks like setting additionalProperties to False doesn't understand patternProperties and validation fails?