error object properties "schema" and "relative_schema_path" seem to be inconsistent
#191 geöffnet am 6. Jan. 2015
Repository-Metriken
- Stars
- (4.349 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 2T 23h) (6 gemergte PRs in 30 T)
Beschreibung
I need to parse a jsonschema.exceptions.ValidationError object to help produce a more useful error message to my customers, but I am not sure that the fields of the ValidationError object are correct.
Test case: https://gist.github.com/jason-s/6d2b3418f4edb7fc8064
Raw object (in yaml format, but jsonschema is representation-agnostic -- thank you, it means I can use it for yaml files):
debug:
foo:
bar:
jiminy: cricket
mickey: mouse
44hoho: twinkie
The validator correctly find that 44hoho is not a legal property name; it doesn't match patternProperties and in my schema I have additionalProperties = false.
The problem is that the error object's relative_schema_path and schema seem inconsistent.
My test case prints:
parent : None
relative_path : deque(['debug', 'foo', 'bar'])
relative_schema_path: deque(['properties', 'debug', 'properties', 'foo', 'properties', 'bar', 'additionalProperties'])
instance : {'jiminy': 'cricket', 'mickey': 'mouse', '44hoho': 'twinkie'}
schema_path : deque(['properties', 'debug', 'properties', 'foo', 'properties', 'bar', 'additionalProperties'])
validator : additionalProperties
context : []
path : deque(['debug', 'foo', 'bar'])
message : Additional properties are not allowed ('44hoho' was unexpected)
schema : {'additionalProperties': False, 'type': 'object', 'patternProperties': {'^[^\\d\\W]\\w*$': {'type': 'string'}}}
cause : None
validator_value: False
Note that the schema attribute is a sub-portion of the schema object, but the relative schema path is from the root schema.