Non-deterministic match?

9 views
Skip to first unread message

Samuele Pilleri

unread,
Oct 22, 2018, 6:29:14 AM10/22/18
to jsonschema - An implementation of JSON Schema for Python
Hello,

I thought this would be a more appropriate place for this question rather than Github.

I have an array of objects whose items only differ in a specific deep-nested field. Possible sub-schemas are strictly defined in two separate definitions and every object's properties are enforced with "required" and "additionalProperties" rules (the latter set to false).

When I try to match the whole input I expect the validator to try using a rule and, if it fails, try with the other one; instead it fails and reports that it couldn't match a given rule because it could not find a required field.

I wonder if this is expected-by-design (hence the title), a bug or if anyone knows a workaround.

Regards,
- Samuele

Julian Berman

unread,
Oct 22, 2018, 8:09:01 PM10/22/18
to Samuele Pilleri, jsonschema - An implementation of JSON Schema for Python
Hi.

Hard to tell what you mean.

If you can't get a schema to do what you're looking for please share a minimal example with sample instance.

-J

--
You received this message because you are subscribed to the Google Groups "jsonschema - An implementation of JSON Schema for Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonschema+...@googlegroups.com.
To post to this group, send email to jsons...@googlegroups.com.

Samuele Pilleri

unread,
Oct 23, 2018, 4:02:17 AM10/23/18
to jsons...@googlegroups.com
Julian,

Thank you for taking the time to read this.

What I was trying to do was matching against an array whose elements can only be of a finite set of types. It turns out I had misunderstood the docs and instead of using the "oneOf" (or "anyOf") operator, I was doing tuple validation, my bad.

Now I'm looking for a way to get an "annotated tree" (actually, a simple callback every time a match is found would do it) out of the validator. The specification doesn't seem to be very clear and I'm not sure your implementation supports it (a quick search of the docs doesn't give any result for "annotate", "annotation" or "callback"). I hope there is a way around this.

- S
Reply all
Reply to author
Forward
0 new messages