java-json-tools / json-schema-validator

A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order
http://json-schema-validator.herokuapp.com/
Other
1.63k stars 399 forks source link

False negative: mutually exclusive cases of oneOf all match #279

Closed reitzig closed 5 years ago

reitzig commented 6 years ago

The following pair should validate:

For reference, this exact pair validates with Ruby's json-schema.

However, with json-schema-validator (2.2.10) I get:

instance failed to match exactly one schema (matched 3 out of 3)

There are two three-way oneOfs in this schema:

In summary, it is impossible for any JSON to cause this error (and the given one certainly doesn't), There must be a bug in the validator.

reitzig commented 5 years ago

This may be related to json-schema-org/json-schema-spec/issues#672, in which case it's not a bug at all but the specified (or at least intended, at draft 4) behaviour.

reitzig commented 5 years ago

I have confirmed that with the corrected schema the result is as expected. My apologies.