Skip to content

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

@martinpengellyphillips

Description

@martinpengellyphillips

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions