152 lines
4.5 KiB
JSON
152 lines
4.5 KiB
JSON
[
|
|
{
|
|
"description": "additionalProperties validates properties not matched by properties",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$id": "schema1",
|
|
"properties": {
|
|
"foo": {
|
|
"type": "string"
|
|
},
|
|
"bar": {
|
|
"type": "number"
|
|
}
|
|
},
|
|
"additionalProperties": {
|
|
"type": "boolean"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "defined properties are valid",
|
|
"data": {
|
|
"foo": "value",
|
|
"bar": 123
|
|
},
|
|
"valid": true,
|
|
"schema_id": "schema1"
|
|
},
|
|
{
|
|
"description": "additional property matching schema is valid",
|
|
"data": {
|
|
"foo": "value",
|
|
"is_active": true,
|
|
"hidden": false
|
|
},
|
|
"valid": true,
|
|
"schema_id": "schema1"
|
|
},
|
|
{
|
|
"description": "additional property not matching schema is invalid",
|
|
"data": {
|
|
"foo": "value",
|
|
"is_active": 1
|
|
},
|
|
"valid": false,
|
|
"schema_id": "schema1"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true with additionalProperties still validates structure",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"properties": {
|
|
"foo": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"extensible": true,
|
|
"additionalProperties": {
|
|
"type": "integer"
|
|
},
|
|
"$id": "additionalProperties_1_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "additional property matching schema is valid",
|
|
"data": {
|
|
"foo": "hello",
|
|
"count": 5,
|
|
"age": 42
|
|
},
|
|
"valid": true,
|
|
"schema_id": "additionalProperties_1_0"
|
|
},
|
|
{
|
|
"description": "additional property not matching schema is invalid despite extensible: true",
|
|
"data": {
|
|
"foo": "hello",
|
|
"count": "five"
|
|
},
|
|
"valid": false,
|
|
"schema_id": "additionalProperties_1_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "complex additionalProperties with object and array items",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"$id": "schema3",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"additionalProperties": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid array of strings",
|
|
"data": {
|
|
"type": "my_type",
|
|
"group_a": [
|
|
"field1",
|
|
"field2"
|
|
],
|
|
"group_b": [
|
|
"field3"
|
|
]
|
|
},
|
|
"valid": true,
|
|
"schema_id": "schema3"
|
|
},
|
|
{
|
|
"description": "invalid array of integers",
|
|
"data": {
|
|
"type": "my_type",
|
|
"group_a": [
|
|
1,
|
|
2
|
|
]
|
|
},
|
|
"valid": false,
|
|
"schema_id": "schema3"
|
|
},
|
|
{
|
|
"description": "invalid non-array type",
|
|
"data": {
|
|
"type": "my_type",
|
|
"group_a": "field1"
|
|
},
|
|
"valid": false,
|
|
"schema_id": "schema3"
|
|
}
|
|
]
|
|
}
|
|
] |