226 lines
6.3 KiB
JSON
226 lines
6.3 KiB
JSON
[
|
|
{
|
|
"description": "merging: properties accumulate",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"base": {
|
|
"properties": {
|
|
"base_prop": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"$ref": "#/$defs/base",
|
|
"properties": {
|
|
"child_prop": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid with both properties",
|
|
"data": {
|
|
"base_prop": "a",
|
|
"child_prop": "b"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid when base property has wrong type",
|
|
"data": {
|
|
"base_prop": 1,
|
|
"child_prop": "b"
|
|
},
|
|
"valid": false,
|
|
"expect_errors": [
|
|
{
|
|
"code": "TYPE_MISMATCH",
|
|
"path": "/base_prop"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "merging: required fields accumulate",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"base": {
|
|
"properties": {
|
|
"a": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"a"
|
|
]
|
|
}
|
|
},
|
|
"$ref": "#/$defs/base",
|
|
"properties": {
|
|
"b": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"b"
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid when both present",
|
|
"data": {
|
|
"a": "ok",
|
|
"b": "ok"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid when base required missing",
|
|
"data": {
|
|
"b": "ok"
|
|
},
|
|
"valid": false,
|
|
"expect_errors": [
|
|
{
|
|
"code": "REQUIRED_FIELD_MISSING",
|
|
"path": "/a"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "invalid when child required missing",
|
|
"data": {
|
|
"a": "ok"
|
|
},
|
|
"valid": false,
|
|
"expect_errors": [
|
|
{
|
|
"code": "REQUIRED_FIELD_MISSING",
|
|
"path": "/b"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "merging: dependencies accumulate",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"base": {
|
|
"properties": {
|
|
"trigger": {
|
|
"type": "string"
|
|
},
|
|
"base_dep": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"dependencies": {
|
|
"trigger": [
|
|
"base_dep"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"$ref": "#/$defs/base",
|
|
"properties": {
|
|
"child_dep": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"dependencies": {
|
|
"trigger": [
|
|
"child_dep"
|
|
]
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid with all deps",
|
|
"data": {
|
|
"trigger": "go",
|
|
"base_dep": "ok",
|
|
"child_dep": "ok"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid missing base dep",
|
|
"data": {
|
|
"trigger": "go",
|
|
"child_dep": "ok"
|
|
},
|
|
"valid": false,
|
|
"expect_errors": [
|
|
{
|
|
"code": "DEPENDENCY_FAILED",
|
|
"path": "/base_dep"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "invalid missing child dep",
|
|
"data": {
|
|
"trigger": "go",
|
|
"base_dep": "ok"
|
|
},
|
|
"valid": false,
|
|
"expect_errors": [
|
|
{
|
|
"code": "DEPENDENCY_FAILED",
|
|
"path": "/child_dep"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "merging: form and display do NOT merge",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"base": {
|
|
"properties": {
|
|
"a": {
|
|
"type": "string"
|
|
},
|
|
"b": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"form": [
|
|
"a",
|
|
"b"
|
|
]
|
|
}
|
|
},
|
|
"$ref": "#/$defs/base",
|
|
"properties": {
|
|
"c": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"form": [
|
|
"c"
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "child schema validation",
|
|
"data": {
|
|
"a": "ok",
|
|
"b": "ok",
|
|
"c": "ok"
|
|
},
|
|
"valid": true,
|
|
"comment": "Verifies validator handles the unmerged metadata correctly (ignores it or handles replacement)"
|
|
}
|
|
]
|
|
}
|
|
] |