Skip to content

Commit 54fcac3

Browse files
committed
Pass the rest of the 2020 and 2019 keywords tests.
1 parent c398c6f commit 54fcac3

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

referencing/jsonschema.py

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def _subresources_of(
126126
in_value: Set[str] = frozenset(),
127127
in_subvalues: Set[str] = frozenset(),
128128
in_subarray: Set[str] = frozenset(),
129+
in_value_or_subarray: Set[str] = frozenset(),
129130
):
130131
"""
131132
Create a callable returning JSON Schema specification-style subschemas.
@@ -146,6 +147,13 @@ def subresources_of(contents: Schema) -> Iterable[ObjectSchema]:
146147
for each in in_subvalues:
147148
if each in contents:
148149
yield from contents[each].values()
150+
for each in in_value_or_subarray:
151+
if each in contents:
152+
value = contents[each]
153+
if isinstance(value, Mapping):
154+
yield value
155+
else:
156+
yield from value
149157

150158
return subresources_of
151159

@@ -154,19 +162,54 @@ def subresources_of(contents: Schema) -> Iterable[ObjectSchema]:
154162
name="draft2020-12",
155163
id_of=_dollar_id,
156164
subresources_of=_subresources_of(
157-
in_value={"additionalProperties", "if", "then", "else", "not"},
158-
in_subarray={"allOf", "anyOf", "oneOf"},
159-
in_subvalues={"$defs", "properties"},
165+
in_value={
166+
"additionalProperties",
167+
"contains",
168+
"contentSchema",
169+
"else",
170+
"if",
171+
"items",
172+
"not",
173+
"propertyNames",
174+
"then",
175+
"unevaluatedItems",
176+
"unevaluatedProperties",
177+
},
178+
in_subarray={"allOf", "anyOf", "oneOf", "prefixItems"},
179+
in_subvalues={
180+
"$defs",
181+
"dependentSchemas",
182+
"patternProperties",
183+
"properties",
184+
},
160185
),
161186
anchors_in=_anchor,
162187
)
163188
DRAFT201909 = Specification(
164189
name="draft2019-09",
165190
id_of=_dollar_id,
166191
subresources_of=_subresources_of(
167-
in_value={"additionalProperties", "if", "then", "else", "not"},
192+
in_value={
193+
"additionalItems",
194+
"additionalProperties",
195+
"contains",
196+
"contentSchema",
197+
"if",
198+
"then",
199+
"else",
200+
"not",
201+
"propertyNames",
202+
"unevaluatedItems",
203+
"unevaluatedProperties",
204+
},
168205
in_subarray={"allOf", "anyOf", "oneOf"},
169-
in_subvalues={"$defs", "properties"},
206+
in_subvalues={
207+
"$defs",
208+
"dependentSchemas",
209+
"patternProperties",
210+
"properties",
211+
},
212+
in_value_or_subarray={"items"},
170213
),
171214
anchors_in=_anchor_2019,
172215
)

suite

Submodule suite updated 31 files

0 commit comments

Comments
 (0)