Skip to content

Commit 78c8742

Browse files
committed
Add support for the non-recursiveRef parts of 2019.
1 parent 377489b commit 78c8742

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

referencing/jsonschema.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ def _legacy_id(contents: ObjectSchema) -> URI | None:
5151
return id
5252

5353

54+
def _anchor_2019(
55+
specification: Specification[Schema],
56+
contents: Schema,
57+
) -> Iterable[Anchor[Schema]]:
58+
if isinstance(contents, bool):
59+
return []
60+
anchor = contents.get("$anchor")
61+
if anchor is None:
62+
return []
63+
return [
64+
Anchor(
65+
name=anchor,
66+
resource=specification.create_resource(contents),
67+
),
68+
]
69+
70+
5471
def _legacy_anchor_in_dollar_id(
5572
specification: Specification[Schema],
5673
contents: Schema,
@@ -120,8 +137,12 @@ def subresources_of(contents: Schema) -> Iterable[ObjectSchema]:
120137
DRAFT201909 = Specification(
121138
name="draft2019-09",
122139
id_of=_dollar_id,
123-
subresources_of=lambda contents: [],
124-
anchors_in=lambda specification, contents: [],
140+
subresources_of=_subresources_of(
141+
in_value={"if", "then", "else", "not"},
142+
in_subarray={"allOf", "anyOf", "oneOf"},
143+
in_subvalues={"$defs", "properties"},
144+
),
145+
anchors_in=_anchor_2019,
125146
)
126147
DRAFT7 = Specification(
127148
name="draft-07",

0 commit comments

Comments
 (0)