Skip to content

Commit 7255b4c

Browse files
committed
#782: Add compatibility to draft7 and older
1 parent 9394023 commit 7255b4c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

jsonschema/validators.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,22 @@ def iter_errors(self, instance, _schema=None):
161161
if scope:
162162
self.resolver.push_scope(scope)
163163
try:
164-
validators = []
165-
166-
# We make sure $ref is evaluated first if available in schema
167-
ref = _schema.get(u"$ref")
168-
if ref is not None:
169-
validators = [(u"$ref", ref)]
170-
171-
# Add all remaining validators
172-
validators += [(x, _schema[x]) for x in _schema if x not in ["$ref"]]
164+
if isinstance(self, Draft202012Validator):
165+
validators = []
166+
# We make sure $ref is evaluated first if available in schema
167+
ref = _schema.get(u"$ref")
168+
if ref is not None:
169+
validators = [(u"$ref", ref)]
170+
171+
# Add all remaining validators
172+
validators += [(x, _schema[x]) for x in _schema if x not in ["$ref"]]
173+
else:
174+
# Compatibility to Draft7 and older
175+
ref = _schema.get(u"$ref")
176+
if ref is not None:
177+
validators = [(u"$ref", ref)]
178+
else:
179+
validators = _schema.items()
173180

174181
for k, v in validators:
175182
validator = self.VALIDATORS.get(k)

0 commit comments

Comments
 (0)