I'm trying to validate a JSON within its associated schema.
I'm validating using the following website : https://www.jsonschemavalidator.net/
My test data looks like this
[
{
"testString": "string value",
"testInt": 1
},
{
"testString": "another string value",
"testInt": 2
}
]
And the schema is defined as follow
{
"type": "array",
"items": [
{
"type": "object",
"properties": {
"testString": {
"type": "string"
},
"testInt": {
"type": "integer"
}
},
"required": [
"testString",
"testInt"
],
"additionalProperties": false
}
]
}
It works well for the given example, however if I add an unexpected attribute into the second element it's not detected as an error. Otherwise it is if I add it into the first element
So this works (detected as wrong JSON)
[
{
"testString": "string value",
"testInt": 1,
"unexpectedAttribute": "unexpected value"
},
{
"testString": "another string value",
"testInt": 2
}
]
But this doesn't works (detected as valid JSON)
[
{
"testString": "string value",
"testInt": 1
},
{
"testString": "another string value",
"testInt": 2,
"unexpectedAttribute": "unexpected value"
}
]
I also tried with this website but I have the same result, so I think that I may have forgotten something into my schema.
Does anybody already faced the same issue ?