Files
jspg/fixtures/objectTypes.json

183 lines
3.8 KiB
JSON

[
{
"description": "Strict Inheritance",
"database": {
"schemas": {
"parent_type": {
"type": "object",
"properties": {
"a": {
"type": "integer"
}
},
"required": [
"a"
]
},
"child_type": {
"type": "parent_type",
"properties": {
"b": {
"type": "integer"
}
}
}
}
},
"tests": [
{
"description": "valid child inherits properties and strictness",
"schema_id": "child_type",
"data": {
"a": 1,
"b": 2
},
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "missing inherited required property fails",
"schema_id": "child_type",
"data": {
"b": 2
},
"action": "validate",
"expect": {
"success": false
}
},
{
"description": "additional properties fail due to inherited strictness",
"schema_id": "child_type",
"data": {
"a": 1,
"b": 2,
"c": 3
},
"action": "validate",
"expect": {
"success": false
}
}
]
},
{
"description": "Local Shadowing (Composition & Proxies)",
"database": {
"schemas": {
"budget": {
"type": "object",
"properties": {
"max": {
"type": "integer",
"maximum": 100
}
}
},
"custom_budget": {
"type": "budget",
"properties": {
"max": {
"type": "integer",
"maximum": 50
}
}
}
}
},
"tests": [
{
"description": "shadowing override applies (50 is locally allowed)",
"schema_id": "custom_budget",
"data": {
"max": 40
},
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "shadowing override applies natively, rejecting 60 even though parent allowed 100",
"schema_id": "custom_budget",
"data": {
"max": 60
},
"action": "validate",
"expect": {
"success": false
}
}
]
},
{
"description": "Primitive Array Shorthand (Optionality)",
"database": {
"schemas": {
"invoice": {
"type": "object",
"properties": {
"amount": {
"type": "integer"
}
},
"required": [
"amount"
]
},
"request": {
"type": "object",
"properties": {
"inv": {
"type": [
"invoice",
"null"
]
}
}
}
}
},
"tests": [
{
"description": "valid object passes shorthand inheritance check",
"schema_id": "request",
"data": {
"inv": {
"amount": 5
}
},
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "null passes shorthand inheritance check",
"schema_id": "request",
"data": {
"inv": null
},
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "invalid object fails inner constraints safely",
"schema_id": "request",
"data": {
"inv": {
"amount": "string"
}
},
"action": "validate",
"expect": {
"success": false
}
}
]
}
]