Skip to content

Incorrect index for item error path when additionalItems used. #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
martinpengellyphillips opened this issue Aug 24, 2013 · 1 comment

Comments

@martinpengellyphillips
Copy link

Could be my misunderstanding, but it seems the error path for an item in the below example is being incorrectly set (it should be deque([2]) rather than deque([1])). It only seems to occur when items is non-empty.

from jsonschema import Draft4Validator as Validator

schema = {
    'type': 'array',
    'items': [{
        'type': 'object',
        'properties': {
            'foo': {'type': 'string'}
        },
        'required': ['foo']
    }],
    'additionalItems': {
        'type': 'object',
        'properties': {
            'bar': {'type': 'string'}
        },
        'required': ['bar']
    }
}

instance = [
    {'foo': 'A'},
    {'bar': 'B'},
    {},
]

errors = Validator(schema).iter_errors(instance)
for error in errors:
    print error.path, error.message

# deque([1]) 'bar' is a required property

Note: The aim for this schema is that the first item should be different to all remaining items.

@martinpengellyphillips
Copy link
Author

Confirming that proposed pull request #123 fixes the issue (thanks!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant