java-json-tools / json-schema-validator

A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order
http://json-schema-validator.herokuapp.com/
Other
1.62k stars 399 forks source link

RequiredSyntaxChecker not validating duplicate array elements correctly for required properties array #301

Open suryatej16 opened 5 years ago

suryatej16 commented 5 years ago

The validator has inconsistent behavior when validating duplicate elements in the required properties array. The following two schemas differ only by the order of elements in the required properties array, but one schema is validated successfully, while another fails validation:

Successful Schema

{
    "type": "object",
    "properties": {
        "name__c": {
            "label": "Passenger Name",
            "type": "string",
            "enum": [
                "test",
                "test",
                "noTest"
            ]
        },
        "dateOfBirth__c": {
            "label": "Date of Birth",
            "type": "string",
            "format": "date"
        }
    },
    "required": [
        "name__c",
        "name__c",
        "dateOfBirth__c"
    ]
}

Failed Schema

{
    "type": "object",
    "properties": {
        "name__c": {
            "label": "Passenger Name",
            "type": "string",
            "enum": [
                "test",
                "test",
                "noTest"
            ]
        },
        "dateOfBirth__c": {
            "label": "Date of Birth",
            "type": "string",
            "format": "date"
        }
    },
    "required": [
        "dateOfBirth__c",
        "name__c",
        "name__c"
    ]
}