Skip to content

Commit

Permalink
Merge pull request #862 from jhashkes/fix/prefixitems-indexing
Browse files Browse the repository at this point in the history
Fix prefixItems index reporting in ValidationError
  • Loading branch information
Julian authored Oct 18, 2021
2 parents 2cf3dc2 + ff1a2bf commit 53864d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion jsonschema/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,9 @@ def prefixItems(validator, prefixItems, instance, schema):
return

for (index, item), subschema in zip(enumerate(instance), prefixItems):
yield from validator.descend(item, subschema, schema_path=index)
yield from validator.descend(
instance=item,
schema=subschema,
schema_path=index,
path=index,
)
8 changes: 4 additions & 4 deletions jsonschema/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,10 +1156,10 @@ def test_prefixItems(self):
"type",
"string",
1,
deque([]),
deque([0]),
{"type": "string"},
deque(["prefixItems", 0, "type"]),
"$",
"$[0]",
),
)
self.assertEqual(
Expand All @@ -1178,10 +1178,10 @@ def test_prefixItems(self):
"maximum",
3,
5,
deque([]),
deque([3]),
{"maximum": 3},
deque(["prefixItems", 3, "maximum"]),
"$",
"$[3]",
),
)

Expand Down

0 comments on commit 53864d2

Please sign in to comment.