Skip to content

Commit

Permalink
Look for subschemas in definitions, even in newer dialects.
Browse files Browse the repository at this point in the history
Even though `definitions` was renamed to `$defs`, the JSON Schema
specifications still use SHOULD language when describing preserving
behavior for `definitions`.

Specifically they say:

    implementations SHOULD assume that "$defs" and "definitions" have
    the same behavior when that meta-schema is used.

from https://json-schema.org/draft/2020-12/json-schema-validation#name-keywords-moved-from-validat

Closes: #129
  • Loading branch information
Julian committed Mar 16, 2024
1 parent 55a1ccf commit 685e34c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
=========

v0.34.0
-------

* Also look inside ``definitions`` keywords even on newer dialects.
The specification recommends doing so regardless of the rename to ``$defs``.

v0.33.0
-------

Expand Down
4 changes: 4 additions & 0 deletions referencing/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def maybe_in_subresource(
in_subarray={"allOf", "anyOf", "oneOf", "prefixItems"},
in_subvalues={
"$defs",
"definitions",
"dependentSchemas",
"patternProperties",
"properties",
Expand All @@ -400,6 +401,7 @@ def maybe_in_subresource(
in_subarray={"allOf", "anyOf", "oneOf", "prefixItems"},
in_subvalues={
"$defs",
"definitions",
"dependentSchemas",
"patternProperties",
"properties",
Expand Down Expand Up @@ -427,6 +429,7 @@ def maybe_in_subresource(
in_subarray={"allOf", "anyOf", "oneOf"},
in_subvalues={
"$defs",
"definitions",
"dependentSchemas",
"patternProperties",
"properties",
Expand All @@ -450,6 +453,7 @@ def maybe_in_subresource(
in_subarray={"allOf", "anyOf", "oneOf"},
in_subvalues={
"$defs",
"definitions",
"dependentSchemas",
"patternProperties",
"properties",
Expand Down

0 comments on commit 685e34c

Please sign in to comment.