diff options
author | Jonathan Hashkes <jhashkes@gmail.com> | 2021-10-17 23:45:52 -0400 |
---|---|---|
committer | Jonathan Hashkes <jhashkes@gmail.com> | 2021-10-17 23:45:52 -0400 |
commit | ff1a2bfdf49abb20e6eb3888f8ffe53d8a678b33 (patch) | |
tree | cca938b1293ac0b147c1255d1a13f2622e3716a2 | |
parent | 2cf3dc20dffca01335c806db48b4a584baf8583f (diff) | |
download | jsonschema-ff1a2bfdf49abb20e6eb3888f8ffe53d8a678b33.tar.gz |
fix prefixItems index reporting in ValidationError
-rw-r--r-- | jsonschema/_validators.py | 7 | ||||
-rw-r--r-- | jsonschema/tests/test_validators.py | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/jsonschema/_validators.py b/jsonschema/_validators.py index e0845ea..3929599 100644 --- a/jsonschema/_validators.py +++ b/jsonschema/_validators.py @@ -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, + ) diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 5fabff9..5786173 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -1156,10 +1156,10 @@ class TestValidationErrorDetails(TestCase): "type", "string", 1, - deque([]), + deque([0]), {"type": "string"}, deque(["prefixItems", 0, "type"]), - "$", + "$[0]", ), ) self.assertEqual( @@ -1178,10 +1178,10 @@ class TestValidationErrorDetails(TestCase): "maximum", 3, 5, - deque([]), + deque([3]), {"maximum": 3}, deque(["prefixItems", 3, "maximum"]), - "$", + "$[3]", ), ) |