128 lines
3.5 KiB
JSON
128 lines
3.5 KiB
JSON
[
|
|
{
|
|
"description": "override: true replaces base property definition",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"base": {
|
|
"properties": {
|
|
"foo": {
|
|
"type": "string",
|
|
"minLength": 5
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"$ref": "#/$defs/base",
|
|
"properties": {
|
|
"foo": {
|
|
"type": "integer",
|
|
"override": true
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid integer (overrides string type)",
|
|
"data": {
|
|
"foo": 123
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid integer (overrides string type)",
|
|
"data": {
|
|
"foo": "abc"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "override: true in nested schema",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"base": {
|
|
"properties": {
|
|
"config": {
|
|
"properties": {
|
|
"mode": {
|
|
"const": "auto"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"$ref": "#/$defs/base",
|
|
"properties": {
|
|
"config": {
|
|
"properties": {
|
|
"mode": {
|
|
"const": "manual",
|
|
"override": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "matches overridden const",
|
|
"data": {
|
|
"config": {
|
|
"mode": "manual"
|
|
}
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "does not match base const",
|
|
"data": {
|
|
"config": {
|
|
"mode": "auto"
|
|
}
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "override: false (default) behavior (intersection)",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"base": {
|
|
"properties": {
|
|
"foo": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"$ref": "#/$defs/base",
|
|
"properties": {
|
|
"foo": {
|
|
"minLength": 2
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid intersection",
|
|
"data": {
|
|
"foo": "ok"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid intersection (wrong type)",
|
|
"data": {
|
|
"foo": 123
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
}
|
|
] |