Skip to content

Commit 52a11b6

Browse files
committed
Booleans have no subresources (when they exist at all).
1 parent f36ea19 commit 52a11b6

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

referencing/jsonschema.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,18 @@ def _subresources_of(
7676
values, in a subobject's values, or in a subarray.
7777
"""
7878

79-
def subresources_of(resource: ObjectSchema) -> Iterable[ObjectSchema]:
79+
def subresources_of(contents: Schema) -> Iterable[ObjectSchema]:
80+
if isinstance(contents, bool):
81+
return
8082
for each in in_value:
81-
if each in resource:
82-
yield resource[each]
83+
if each in contents:
84+
yield contents[each]
8385
for each in in_subarray:
84-
if each in resource:
85-
yield from resource[each]
86+
if each in contents:
87+
yield from contents[each]
8688
for each in in_subvalues:
87-
if each in resource:
88-
yield from resource[each].values()
89+
if each in contents:
90+
yield from contents[each].values()
8991

9092
return subresources_of
9193

referencing/tests/test_jsonschema.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ def test_anchors_in_bool(specification, value):
9393
assert specification.anchors_in(value) == []
9494

9595

96+
@pytest.mark.parametrize(
97+
"specification",
98+
[
99+
referencing.jsonschema.DRAFT202012,
100+
referencing.jsonschema.DRAFT201909,
101+
referencing.jsonschema.DRAFT7,
102+
referencing.jsonschema.DRAFT6,
103+
],
104+
)
105+
@pytest.mark.parametrize("value", [True, False])
106+
def test_subresources_of_bool(specification, value):
107+
assert list(specification.subresources_of(value)) == []
108+
109+
96110
@pytest.mark.parametrize(
97111
"uri, expected",
98112
[

0 commit comments

Comments
 (0)