Skip to content

Commit 53864d2

Browse files
authored
Merge pull request #862 from jhashkes/fix/prefixitems-indexing
Fix prefixItems index reporting in ValidationError
2 parents 2cf3dc2 + ff1a2bf commit 53864d2

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

jsonschema/_validators.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,9 @@ def prefixItems(validator, prefixItems, instance, schema):
452452
return
453453

454454
for (index, item), subschema in zip(enumerate(instance), prefixItems):
455-
yield from validator.descend(item, subschema, schema_path=index)
455+
yield from validator.descend(
456+
instance=item,
457+
schema=subschema,
458+
schema_path=index,
459+
path=index,
460+
)

jsonschema/tests/test_validators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,10 +1156,10 @@ def test_prefixItems(self):
11561156
"type",
11571157
"string",
11581158
1,
1159-
deque([]),
1159+
deque([0]),
11601160
{"type": "string"},
11611161
deque(["prefixItems", 0, "type"]),
1162-
"$",
1162+
"$[0]",
11631163
),
11641164
)
11651165
self.assertEqual(
@@ -1178,10 +1178,10 @@ def test_prefixItems(self):
11781178
"maximum",
11791179
3,
11801180
5,
1181-
deque([]),
1181+
deque([3]),
11821182
{"maximum": 3},
11831183
deque(["prefixItems", 3, "maximum"]),
1184-
"$",
1184+
"$[3]",
11851185
),
11861186
)
11871187

0 commit comments

Comments
 (0)