python-jsonschema / python-jsonschema/jsonschema
Idea: warn on unsupported keywords (e.g. "const" in draft-04 schemas)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5k
- Forks
- 671
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Description
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, andconst(added in draft06) - <= draft06, warn on
if,then, andelse(added in draft07) - In draft07, the
mediakeyword was replaced withcontentMediaTypeandcontentEncoding, 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the validate example and the DraftXValidator implementations. Review how each draft handles schema keywords, then define warning behavior for the listed newer or renamed keywords while preserving the existing treatment of unknown format values; verify the warnings across the affected draft validators.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100