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

Idea: warn on unsupported keywords (e.g. "const" in draft-04 schemas) #778

Open
Zac-HD opened this issue Feb 3, 2021 · 1 comment
Open
Labels
Dialects v2 Issues which will likely be addressed as part of reworked dialect support Enhancement Some new desired functionality

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Feb 3, 2021

I just spent a few minutes digging into a test failure which boiled down to the following:

from jsonschema import validate

schema = {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "const": None,
}
validate("literally anything validates", schema)

which is of course because the const keyword was added in draft-06! Since I've seen analogous problems several times now, I wonder if we should make the earlier DraftXValidators emit a warning when they see a keyword which was added in a later draft. That would be:

  • <= draft04, warn on propertyNames, contains, and const (added in draft06)
  • <= draft06, warn on if, then, and else (added in draft07)
  • In draft07, the media keyword was replaced with contentMediaType and contentEncoding, so warnings on both sides could help
  • <= draft07... there are lots

I've ignored the string format values, because they explictly permit ignoring unknown values and it's reasonable to think that users might have backported a check - whereas the too-new keywords are almost certainly a programmer error.

@PatMyron
Copy link

PatMyron commented May 12, 2021

similar: #766

@Julian Julian added the Enhancement Some new desired functionality label Nov 19, 2021
@Julian Julian added the Dialects v2 Issues which will likely be addressed as part of reworked dialect support label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dialects v2 Issues which will likely be addressed as part of reworked dialect support Enhancement Some new desired functionality
Projects
None yet
Development

No branches or pull requests

3 participants