Add tests for unevaluatedItems interaction with contains
ref json-schema-org/JSON-Schema-Test-Suite#293
"valid": false
}
]
+ },
+ {
+ "description": "unevaluatedItems depends on adjacent contains",
+ "schema": {
+ "prefixItems": [true],
+ "contains": {"type": "string"},
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "second item is evaluated by contains",
+ "data": [ 1, "foo" ],
+ "valid": true
+ },
+ {
+ "description": "contains fails, second item is not evaluated",
+ "data": [ 1, 2 ],
+ "valid": false
+ },
+ {
+ "description": "contains passes, second item is not evaluated",
+ "data": [ 1, 2, "foo" ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems depends on nested contains",
+ "schema": {
+ "anyOf": [
+ {
+ "prefixItems": [{"type": "integer"}]
+ },
+ {
+ "contains": {"type": "string"}
+ }
+ ],
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "single integer is evaluated by prefixItems",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "single string is evaluated by contains",
+ "data": [ "foo" ],
+ "valid": true
+ },
+ {
+ "description": "second item is evaluated by contains",
+ "data": [ 1, "foo" ],
+ "valid": true
+ },
+ {
+ "description": "second item is not evaluated, contains fails",
+ "data": [ 1, 2 ],
+ "valid": false
+ },
+ {
+ "description": "second item is not evaluated, contains passes",
+ "data": [ 1, 2, "foo" ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems depends on multiple nested contains",
+ "schema": {
+ "allOf": [
+ {
+ "prefixItems": [true]
+ },
+ {
+ "contains": {"multipleOf": 2}
+ }
+ ],
+ "anyOf": [
+ {
+ "prefixItems": [true]
+ },
+ {
+ "contains": {"multipleOf": 3}
+ }
+ ],
+ "unevaluatedItems": {
+ "multipleOf": 5
+ }
+ },
+ "tests": [
+ {
+ "description": "second item is evaluated by contains #1",
+ "data": [ 1, 2 ],
+ "valid": true
+ },
+ {
+ "description": "third item is evaluated by contains #2",
+ "data": [ 1, 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "items 3, 4 are evaluated by contains #2, #1",
+ "data": [ 1, 2, 3, 4 ],
+ "valid": true
+ },
+ {
+ "description": "item 5 not evaluated, passes unevaluatedItems",
+ "data": [ 1, 2, 3, 4, 5, 6 ],
+ "valid": true
+ },
+ {
+ "description": "item 5 not evaluated, fails unevaluatedItems",
+ "data": [ 1, 2, 3, 4, 7, 8 ],
+ "valid": false
+ }
+ ]
}
]
