Skip to content

Commit f713389

Browse files
committed
Look for schemas in definitions.
1 parent 4d74609 commit f713389

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

referencing/jsonschema.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def _legacy_id(contents: ObjectSchema) -> URI | None:
3939
return contents.get("id")
4040

4141

42-
def _subresources_of(values: Set[str] = frozenset()):
42+
def _subresources_of(
43+
in_value: Set[str] = frozenset(),
44+
in_subvalues: Set[str] = frozenset(),
45+
):
4346
"""
4447
Create a callable returning JSON Schema specification-style subschemas.
4548
@@ -48,9 +51,12 @@ def _subresources_of(values: Set[str] = frozenset()):
4851
"""
4952

5053
def subresources_of(resource: ObjectSchema) -> Iterable[ObjectSchema]:
51-
for each in values:
54+
for each in in_value:
5255
if each in resource:
5356
yield resource[each]
57+
for each in in_subvalues:
58+
if each in resource:
59+
yield from resource[each].values()
5460

5561
return subresources_of
5662

@@ -68,7 +74,10 @@ def subresources_of(resource: ObjectSchema) -> Iterable[ObjectSchema]:
6874
DRAFT7 = Specification(
6975
name="draft-07",
7076
id_of=_dollar_id,
71-
subresources_of=_subresources_of(values={"if", "then", "else"}),
77+
subresources_of=_subresources_of(
78+
in_value={"if", "then", "else"},
79+
in_subvalues={"definitions"},
80+
),
7281
)
7382
DRAFT6 = Specification(
7483
name="draft-06",

0 commit comments

Comments
 (0)