-
-
Notifications
You must be signed in to change notification settings - Fork 313
Spec and meta-schema seem inconsistent w.r.t empty "type" array #1404
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
Comments
I'm not sure I'd agree with "inconsistent", the spec doesn't say anything specifically about this case, and given the metaschema disallows this it seems more to me like the situation is that the spec is implicitly saying this isn't valid (and the metaschema is enforcing something not explicitly called out). But the end result (of this issue) is likely the same, namely: "call out explicitly in the spec that |
Let me quote the relevant text (type keyword) from the spec
No mention of an non-empty here array.
Does not affect array.
So this is an logical OR connection for the entries in the type array. The empty logical OR is false. For me this is very clear, with little room for interpretation. For comparison see the definition of anyOf (which is also a logical OR). There non-empty array anyOf is explicitly mentioned. But anyway you are of course right: the wording should be fixed in a future draft. |
It seems to me an empty array should be permitted, even if it has limited practical use, it does mean something consistent (it's not completely nonsensical). In particular, you can easily use |
@aha79 I think the magic is contained in this sentence (and a bit to @awwright's point):
If the array is empty, then there are no strings to match an instance to, and thus every instance will fail. It then seems reasonable that one could assume the array must be non-empty. This does seem rather implicit, and I'm not against adding the text that @Julian mentioned as a clarification. |
To be extra explicit, I see no good reason personally for
We should not add noisy extra ways to spell clear concepts, and even more so should err on the side of making or keeping as many useless schemas invalid as is possible whenever such a constraint is expressable in a metaschema, i.e. within the language of JSON Schema's official dialect. |
Action here is to add a requirement that the |
The spec allows
"type": []
, but in the validation vocabuary there is a 'minItems: 1' for the "type" property. This seems inconsistent.For details see this issue I filed earlier with the test-suite (but that was the wrong place): json-schema-org/JSON-Schema-Test-Suite#673
The text was updated successfully, but these errors were encountered: