ajv/spec/security/array.json

105 lines
2.8 KiB
JSON

[
{
"description": "uniqueItems without type keyword should be used together with maxItems",
"schema": {"$ref": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-secure.json#"},
"tests": [
{
"description": "uniqueItems keyword used without maxItems is unsafe",
"data": {
"uniqueItems": true
},
"valid": false
},
{
"description": "uniqueItems keyword used with maxItems is safe",
"data": {
"uniqueItems": true,
"maxItems": "10"
},
"valid": true
},
{
"description": "uniqueItems: false is ignored (and safe)",
"data": {
"uniqueItems": false
},
"valid": true
}
]
},
{
"description": "uniqueItems with scalar type(s) is safe to use without maxItems",
"schema": {"$ref": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-secure.json#"},
"tests": [
{
"description": "uniqueItems keyword with a single scalar type is safe",
"data": {
"uniqueItems": true,
"items": {
"type": "number"
}
},
"valid": true
},
{
"description": "uniqueItems keyword with multiple scalar types is safe",
"data": {
"uniqueItems": true,
"items": {
"type": ["number", "string"]
}
},
"valid": true
}
]
},
{
"description": "uniqueItems with compound type(s) should be used together with maxItems",
"schema": {"$ref": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-secure.json#"},
"tests": [
{
"description": "uniqueItems keyword with a single compound type and without maxItems is unsafe",
"data": {
"uniqueItems": true,
"items": {
"type": "object"
}
},
"valid": false
},
{
"description": "uniqueItems keyword with a single compound type and with maxItems is safe",
"data": {
"uniqueItems": true,
"maxItems": "10",
"items": {
"type": "object"
}
},
"valid": true
},
{
"description": "uniqueItems keyword with multiple types including compound type and without maxItems is unsafe",
"data": {
"uniqueItems": true,
"items": {
"type": ["array","number"]
}
},
"valid": false
},
{
"description": "uniqueItems keyword with multiple types including compound type and with maxItems is safe",
"data": {
"uniqueItems": true,
"maxItems": "10",
"items": {
"type": ["array","number"]
}
},
"valid": true
}
]
}
]