Consider this schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{ "required": [ "foo" ] },
{ "required": [ "bar" ] },
{ "required": [ "baz" ] }
]
}
And this instance:
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"
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:
We have no indication on which branches match or didn't match the
oneOfat all. Also no indication thatrequiredworked because of the constraint-driven nature of JSON Schema.It would have been nice to get something like this instead: