-
-
Notifications
You must be signed in to change notification settings - Fork 215
Add tests for unevaluatedItems interaction with contains #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for unevaluatedItems interaction with contains #474
Conversation
I believe there's some discussion around additionalItems and contains where it was decided that contains doesn't affect that evaluation. It's likely that unevaluatedItems follows suit. I'll see if I can dig that up. Found it: it's the issue that your issue references: json-schema-org/json-schema-spec#810 There's a lot of discussion in there, and it's worth reading. |
Thanks - I have seen that discussion, and have just read the followup PR: json-schema-org/json-schema-spec#925 I disagree that contains shouldn't affect evaluation. In my view, it is perfectly reasonable to build use cases around the interaction of unevaluatedItems and contains, and I think the 2020-12 spec has it completely right. Consider the following scenario (I will add this as another test case to this PR). This is a contrived example, but it illustrates how the (non)evaluation of contains may be used to control an item dependency relationship. An array may contain any sequence of a's, b's and c's, but it may only contain b's if there is at least one a, and it may only contain c's if there is at least one b. Here is the schema: {
"if": {
"contains": {"const": "a"}
},
"then": {
"if": {
"contains": {"const": "b"}
},
"then": {
"if": {
"contains": {"const": "c"}
}
}
},
"unevaluatedItems": false
} Valid examples:
Invalid examples:
|
We use contains and unevaluatedItems to define a dependency relationship over the array items. The array may contain any sequence of a's, b's and c's, but b's may only be present if there is at least one a, and c's may only be present if there is at least one b.
Unfortunately, that's not how that ended up. The change got pushed through despite continued strong disagreement. |
Co-authored-by: Jason Desrosiers <[email protected]>
Co-authored-by: Jason Desrosiers <[email protected]>
ref #293