156 lines
3.4 KiB
JSON
156 lines
3.4 KiB
JSON
[
|
|
{
|
|
"description": "Dynamic type binding ($sibling.suffix) validation",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "person",
|
|
"schemas": {
|
|
"person.filter": {
|
|
"properties": {
|
|
"age": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "widget",
|
|
"schemas": {
|
|
"widget.filter": {
|
|
"properties": {
|
|
"weight": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "search",
|
|
"schemas": {
|
|
"search": {
|
|
"properties": {
|
|
"kind": {
|
|
"type": "string"
|
|
},
|
|
"filter": {
|
|
"type": "$kind.filter"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Valid person filter payload",
|
|
"data": {
|
|
"kind": "person",
|
|
"filter": {
|
|
"age": 30
|
|
}
|
|
},
|
|
"schema_id": "search",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Invalid person filter payload (fails constraint)",
|
|
"data": {
|
|
"kind": "person",
|
|
"filter": {
|
|
"age": "thirty"
|
|
}
|
|
},
|
|
"schema_id": "search",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"details": {
|
|
"path": "filter/age"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Valid widget filter payload",
|
|
"data": {
|
|
"kind": "widget",
|
|
"filter": {
|
|
"weight": 500
|
|
}
|
|
},
|
|
"schema_id": "search",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "Fails resolution if kind doesn't match an existing schema",
|
|
"data": {
|
|
"kind": "unknown",
|
|
"filter": {
|
|
"weight": 500
|
|
}
|
|
},
|
|
"schema_id": "search",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "DYNAMIC_TYPE_RESOLUTION_FAILED",
|
|
"details": {
|
|
"path": "filter"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"details": {
|
|
"path": "filter/weight"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Fails resolution if discriminator is missing",
|
|
"data": {
|
|
"filter": {
|
|
"weight": 500
|
|
}
|
|
},
|
|
"schema_id": "search",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "DYNAMIC_TYPE_RESOLUTION_FAILED",
|
|
"details": {
|
|
"path": "filter"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"details": {
|
|
"path": "filter/weight"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|