Mis-canonicalisation of `const` in draft04 schemas (not a keyword until draft06)

Offen
#76 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
30/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
backend, testing

Rechercherichtung

Start by reading the schema canonicalisation code and its tests to find how draft-specific keywords are handled; the issue does not name their paths. Reproduce the example with a draft-04 schema and check how const is processed. Done means canonicalisation follows draft-04 semantics and the result matches the stated enum: [None] expectation.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

The const keyword was added in draft-06, and therefore has no effect whatsoever in draft-04 schemas. While authors probably intended to constrain the value somewhat, we still have to follow the spec!

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "oneOf": [{"type": "boolean"}, {"const": None}],
    "type": ["boolean", "null"],
}
# Should canonicalise 
#    {"const": None} -> {}
#    "oneOf": [{"type": "boolean"}, {}] -> "not": {"type": "boolean"}
# and ultimately to
{"enum": [None]}

See also https://github.com/Julian/jsonschema/issues/778; longer term this is another argument for my do-it-right schema processing redesign...

Vorherrschende Sprache
Python
Sterne
281
Forks
35
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python-jsonschema/hypothesis-jsonschema

Alle Issues in python-jsonschema/hypothesis-jsonschema

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.