-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
Meta-schema for enum should allow empty and non-unique arrays #717
Comments
For such short documents, the number of meta-schema bugs is astounding :-/ Certainly related to #618 in that it would be fantastic if someone implemented #618. I supposed we should update them for this (and I think The good news is that the meta-schemas are not normative, so feel free to edit your local copy. |
Issue: json-schema-org#717 enum no longer requires minimum number of items or unique items, in accordance with the spec.
@Zac-HD Correctness is good, but I have to ask, do you have a use case for this? |
I have More generally though, the sole purpose of validation libraries is correctness. If we can't implement the spec that actually exists, why would anyone choose to use jsonschema? |
Ah OK, yup that makes sense. And yes, of course, I agree. I wasn't suggesting we don't fix the issue (I made a PR and it's merged already before my comment). I was more asking, should we change the spec to require this or not. The meta-schemas are always informative as opposed to normative, so if the meta-schema doesn't line up with the spec, we have a problem, and should fix it. |
Yep, I'd certainly consider this closed by #739. Thanks so much for your work! |
Minor fix. More than welcome! |
For breadcrumbs for future-us in case this ever comes up again (and I'm today finding this issue again during some livestream archaeology) -- This is something that changed in Draft 6, so only part of what's here is/was correct -- Specifically, in Draft 4 (and 3), the quoted language is not there, it indeed says MUST. From §5.5.1.1:
Compared to Draft 6 and later which have the quoted language, i.e. SHOULD not MUST. This seems to have changed in cf0ec72 It somehow looked from the above like we'd concluded to change the Draft 3 and 4 metaschemas as well (to not contain |
For draft 4 this pulls in upstream fixes which were not present locally, notably fixing `id` to not have `format: uri` in it, because location independent identifiers are indeed not URIs (they're URI references as later metaschemas use). For enum, on draft 3 and 4, this also *re-adds* constraints that enum items MUST be unique and the array non-empty. In later drafts, this restriction was loosened (see json-schema-org/json-schema-spec@cf0ec72) as well as json-schema-org/json-schema-spec#717 (comment) but in drafts 3 and 4 it is present. The draft 4 metaschema contains these assertions, the draft 3 one is still buggy and does not, so they're just applied locally here. Ref: json-schema-org/json-schema-spec#310
Looks like the proposed changes were made in #739, but the meta-schema listed for draft7 on json-schema.org still contains the restraints. Wanted to put that on your radar since that is how I ended up in the rabbit hole that landed me on this issue! |
@erohmensing those changes went into the meta-schema for the draft that changed the syntax. The older drafts do not change, so their meta-schemas don't either. |
Huh, I thought that draft 7 already contained that change (I added the wrong link above, I apologize and have corrected it) -- referring to the syntax as listed here underneath the Draft7 header versus the metadata schema listed under the same header. |
Currently, the meta-schemas for (at least) drafts 3, 4, 6, and 7 contain the following:
json-schema-spec/schema.json
Lines 139 to 144 in 4e016d9
However, the prose specification says:
Validation therefore ought to allow schema authors to use empty or non-unique arrays, because the RFC 2119 definition of
SHOULD
explicitly permits ignoring such clauses after considering the circumstances. Alternatively, the specification could replaceSHOULD
withMUST
for the relevant constraints.Possibly related to #618? First reported at python-jsonschema/jsonschema#529, via
hypothesis-jsonschema
.The text was updated successfully, but these errors were encountered: