-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Open
Feature
Copy link
Description
Consider this schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{ "required": [ "foo" ] },
{ "required": [ "bar" ] },
{ "required": [ "baz" ] }
]
}
And this instance:
[ { "foo": 1 } ]
Trace validation gives us this:
$ jsonschema validate schema.json instance.json --trace
-> (push) "/oneOf" (LogicalXor)
at ""
at keyword location "file:///Users/jviotti/Projects/playground/schema.json#/oneOf"
at vocabulary "https://json-schema.org/draft/2020-12/vocab/applicator"
<- (fail) "/oneOf" (LogicalXor)
at ""
at keyword location "file:///Users/jviotti/Projects/playground/instance.json#/oneOf"
at vocabulary "https://json-schema.org/draft/2020-12/vocab/applicator"
We have no indication on which branches match or didn't match the oneOf
at all. Also no indication that required
worked because of the constraint-driven nature of JSON Schema.
It would have been nice to get something like this instead:
$ jsonschema validate schema.json instance.json --trace
-> (push) "/oneOf" (LogicalXor)
at ""
at keyword location "file:///Users/jviotti/Projects/playground/schema.json#/oneOf"
at vocabulary "https://json-schema.org/draft/2020-12/vocab/applicator"
-> (push) "/oneOf/0/required"
at ""
-> (pass) "/oneOf/0/required"
at ""
warning: Passed because of a type mismatch
-> (push) "/oneOf/1/required"
at ""
-> (pass) "/oneOf/1/required"
at ""
warning: Passed because of a type mismatch
-> (push) "/oneOf/2/required"
at ""
-> (pass) "/oneOf/2/required"
at ""
warning: Passed because of a type mismatch
<- (fail) "/oneOf" (LogicalXor)
at ""
at keyword location "file:///Users/jviotti/Projects/playground/instance.json#/oneOf"
at vocabulary "https://json-schema.org/draft/2020-12/vocab/applicator"
Metadata
Metadata
Assignees
Labels
No labels