Altered behaviour for unevaluatedProperties
and unevaluatedItems
#67
Replies: 2 comments 4 replies
-
This proposal is how I would have liked to see Example: {
"allOf": [
{
"type": "object",
"contains": { "type": "number" }
}
],
"unevaluatedProperties": { "type": "boolean" }
} { "a": 1, "b": 2, "c": "NaN" } Currently "unevaluated" means not successfully validated, so that would mean properties "a" and "b" would be considered evaluated and "c" would fail the Of course if we change what "unevaluated" means for |
Beta Was this translation helpful? Give feedback.
-
It would also mean that the presence of I will continue to mull, but I think I am okay with this tradeoff. |
Beta Was this translation helpful? Give feedback.
-
related to: #57
I'll start by quoting a discussion I started in the #collaborators slack channel, and then elaborate.
Once again I’ve got one small error in my openapi document, but because it has 500+ “paths” entries in it, I get over 1000 errors in the validation result, all from unevaluatedProperties. this would be so much nicer if unevaluatedProperties also considered errors generated from a specific property in its consideration. i.e. making “unevaluated” be truly unevaluated, not “unsuccessfully evaluated”.
Making this change will make a huge difference in bandwidth in my error payloads 🙂
The openapi schema uses unevaluatedProperties everywhere, so any time you have any validation failure, anywhere in the document, you get unevaluatedProperties errors spewing from all locations, and they are totally unhelpful, not to mention very confusing to anyone who doesn’t have intimate knowledge of how this keyword works (which at this point is pretty much constrained to the dozen people in this room).
I’ve always been a bit bugged the way annotations are overloaded from just being informational (e.g. the metadata vocabulary) to also being used for some applicator keywords.
@Relequestual said: "I know a community discussion is coming, but this approach was an attempt to remove specific linking behaviour between keywords, making it easier to implement extensions.
Without it, most libraries likely wouldn't allow new/additional keywords access to information that it may very well need.
I think annotations is probably a poor choice, and really it's "processing scope data" or something "
I replied:
Yes, we may need to introduce an orthogonal thing that is tracked in dynamic scopes — which also happened for $dynamicAnchor+$dynamicRef. Annotations aren’t widely used yet, but it may become confusing that annotations from “properties” etc are mixed in with annotations from “readOnly” — applications would be interested in the latter but not the former, generally. That is — the annotations from the applicator vocabulary are generally only useful internally; the caller doesn’t care about those (but I’d be interested if someone has a counter-observation there).
This problem is similar to what's described in this discussion about additionalProperties -- annotations produced by adjacent
properties
andpatternProperties
isn't the same as whether that keyword actually exists in the current subschema, as a property in the instance could have been evaluated against one of those keywords and resulted in a failure. So my thought was to redefineunevaluatedProperties
as considering both annotations and errors at the data instance location, which I believe would be consistent. (This still isn't truly identical to "was this property ever evaluated by any subschema, anywhere, because of thenot
keyword, which destroys all errors and annotations from nested subschemas, but I think we can consider this "by design".) This essentially redefinesunevaluatedProperties
to mean what it says, rather than how it is now which is reallyunsuccessfullyEvaluatedProperties
. I see this as a very positive change, and resolves the problem of an explosion of useless errors from a complicated schema that usesunevaluatedProperties
(e.g. openapi).We also may want to consider whether the annotation concept is being misused by the *properties keywords: keywords like
readOnly
,title
anddeprecated
are of interest to the user, but annotations fromproperties
etc are not -- so should they be annotations at all? My impression is that the annotation concept was seen as a convenient way to makeunevaluatedProperties
work, but we could use a totally different mechanism here to track the evaluation status.Beta Was this translation helpful? Give feedback.
All reactions