Skip to content
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

Define how contains interacts with unevaluatedProperties #1135

Closed
jdesrosiers opened this issue Oct 14, 2021 · 3 comments · Fixed by #1136
Closed

Define how contains interacts with unevaluatedProperties #1135

jdesrosiers opened this issue Oct 14, 2021 · 3 comments · Fixed by #1136

Comments

@jdesrosiers
Copy link
Member

We recently (#1092) added support for contains to apply to objects, but we neglected to define how contains interacts with unevaluatedProperties. It should be consistent with how unevaluatedItems works.

Example

{
  "allOf": [
    {
      "type": "object",
      "contains": { "type": "number" }
    }
  ],
  "unevaluatedProperties": { "type": "boolean" }
}
{ "a": 1, "b": 2, "c": "NaN" }

Given this schema and instance, we should expect properties "a" and "b" to be "evaluated" and "c" to be unevaluated. "c" should be validated against the unevaluatedProperties schema and fail because it's not a boolean. However, currently unevaluatedProperties is only defined in terms of properties, patternProperties, additionalProperties, and itself, so contains doesn't create the relevant annotations and all of the properties will be considered unevaluated.

I'll create a PR soon to bring this in sync with the unevaluatedItems behavior.

@karenetheridge
Copy link
Member

karenetheridge commented Oct 17, 2021

That brings in an inconsistency between items (né additionalItems) and additionalProperties. We used to see additionalItems and additionalItems as more or less analogues of each other, with the main difference being that the "index" of an object is a property name rather than an integer, and items are ordered and properties are not. If the application of contains to object properties will negate the application of additionalProperties to those properties, shouldn't applying contains to array items negate the application of items to those items as well?

Does it ever make sense to have contains as a sibling keyword to additionalProperties?

I wonder if we should re-evaluate the interaction of these keywords at the same time as the consideration of how unevaluatedProperties and unevaluatedItems interacts with evaluated-but-not-successfully properties/items in json-schema-org/community#67.

@jdesrosiers
Copy link
Member Author

jdesrosiers commented Oct 18, 2021

@karenetheridge I was so confused by your comment and I think I just figured out why. I used additionalProperties in the issue description instead of unevaluatedProperties. This change should have no effect on additionalProperties. It should only affect how contains interacts with unevaluatedProperties. Does that clear things up? Or am I still missing something?

@jdesrosiers jdesrosiers changed the title Define how contains interacts with additionalProperties Define how contains interacts with unevaluatedProperties Oct 18, 2021
@karenetheridge
Copy link
Member

Yes, much better :D :D :D

@json-schema-org json-schema-org deleted a comment from pix-a11 Nov 7, 2021
@json-schema-org json-schema-org deleted a comment from pix-a11 Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants