Files
jspg/tests/fixtures/oneOf.json

568 lines
16 KiB
JSON

[
{
"description": "oneOf",
"database": {
"schemas": [
{
"oneOf": [
{
"type": "integer"
},
{
"minimum": 2
}
],
"$id": "oneOf_0_0"
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": 1,
"valid": true,
"schema_id": "oneOf_0_0"
},
{
"description": "second oneOf valid",
"data": 2.5,
"valid": true,
"schema_id": "oneOf_0_0"
},
{
"description": "both oneOf valid",
"data": 3,
"valid": false,
"schema_id": "oneOf_0_0"
},
{
"description": "neither oneOf valid",
"data": 1.5,
"valid": false,
"schema_id": "oneOf_0_0"
}
]
},
{
"description": "oneOf with base schema",
"database": {
"schemas": [
{
"type": "string",
"oneOf": [
{
"minLength": 2
},
{
"maxLength": 4
}
],
"$id": "oneOf_1_0"
}
]
},
"tests": [
{
"description": "mismatch base schema",
"data": 3,
"valid": false,
"schema_id": "oneOf_1_0"
},
{
"description": "one oneOf valid",
"data": "foobar",
"valid": true,
"schema_id": "oneOf_1_0"
},
{
"description": "both oneOf valid",
"data": "foo",
"valid": false,
"schema_id": "oneOf_1_0"
}
]
},
{
"description": "oneOf with boolean schemas, all true",
"database": {
"schemas": [
{
"oneOf": [
true,
true,
true
],
"$id": "oneOf_2_0"
}
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false,
"schema_id": "oneOf_2_0"
}
]
},
{
"description": "oneOf with boolean schemas, one true",
"database": {
"schemas": [
{
"oneOf": [
true,
false,
false
],
"$id": "oneOf_3_0"
}
]
},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true,
"schema_id": "oneOf_3_0"
}
]
},
{
"description": "oneOf with boolean schemas, more than one true",
"database": {
"schemas": [
{
"oneOf": [
true,
true,
false
],
"$id": "oneOf_4_0"
}
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false,
"schema_id": "oneOf_4_0"
}
]
},
{
"description": "oneOf with boolean schemas, all false",
"database": {
"schemas": [
{
"oneOf": [
false,
false,
false
],
"$id": "oneOf_5_0"
}
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false,
"schema_id": "oneOf_5_0"
}
]
},
{
"description": "oneOf complex types",
"database": {
"schemas": [
{
"oneOf": [
{
"properties": {
"bar": {
"type": "integer"
}
},
"required": [
"bar"
]
},
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
}
],
"$id": "oneOf_6_0"
}
]
},
"tests": [
{
"description": "first oneOf valid (complex)",
"data": {
"bar": 2
},
"valid": true,
"schema_id": "oneOf_6_0"
},
{
"description": "second oneOf valid (complex)",
"data": {
"foo": "baz"
},
"valid": true,
"schema_id": "oneOf_6_0"
},
{
"description": "both oneOf valid (complex)",
"data": {
"foo": "baz",
"bar": 2
},
"valid": false,
"schema_id": "oneOf_6_0"
},
{
"description": "neither oneOf valid (complex)",
"data": {
"foo": 2,
"bar": "quux"
},
"valid": false,
"schema_id": "oneOf_6_0"
}
]
},
{
"description": "oneOf with empty schema",
"database": {
"schemas": [
{
"oneOf": [
{
"type": "number"
},
{}
],
"$id": "oneOf_7_0"
}
]
},
"tests": [
{
"description": "one valid - valid",
"data": "foo",
"valid": true,
"schema_id": "oneOf_7_0"
},
{
"description": "both valid - invalid",
"data": 123,
"valid": false,
"schema_id": "oneOf_7_0"
}
]
},
{
"description": "oneOf with required",
"database": {
"schemas": [
{
"type": "object",
"properties": {
"foo": true,
"bar": true,
"baz": true
},
"oneOf": [
{
"required": [
"foo",
"bar"
]
},
{
"required": [
"foo",
"baz"
]
}
],
"$id": "oneOf_8_0"
}
]
},
"tests": [
{
"description": "both invalid - invalid",
"data": {
"bar": 2
},
"valid": false,
"schema_id": "oneOf_8_0"
},
{
"description": "first valid - valid",
"data": {
"foo": 1,
"bar": 2
},
"valid": true,
"schema_id": "oneOf_8_0"
},
{
"description": "second valid - valid",
"data": {
"foo": 1,
"baz": 3
},
"valid": true,
"schema_id": "oneOf_8_0"
},
{
"description": "both valid - invalid",
"data": {
"foo": 1,
"bar": 2,
"baz": 3
},
"valid": false,
"schema_id": "oneOf_8_0"
},
{
"description": "extra property invalid (strict)",
"data": {
"foo": 1,
"bar": 2,
"extra": 3
},
"valid": false,
"schema_id": "oneOf_8_0"
}
]
},
{
"description": "oneOf with required (extensible)",
"database": {
"schemas": [
{
"type": "object",
"extensible": true,
"oneOf": [
{
"required": [
"foo",
"bar"
]
},
{
"required": [
"foo",
"baz"
]
}
],
"$id": "oneOf_9_0"
}
]
},
"tests": [
{
"description": "both invalid - invalid",
"data": {
"bar": 2
},
"valid": false,
"schema_id": "oneOf_9_0"
},
{
"description": "first valid - valid",
"data": {
"foo": 1,
"bar": 2
},
"valid": true,
"schema_id": "oneOf_9_0"
},
{
"description": "second valid - valid",
"data": {
"foo": 1,
"baz": 3
},
"valid": true,
"schema_id": "oneOf_9_0"
},
{
"description": "both valid - invalid",
"data": {
"foo": 1,
"bar": 2,
"baz": 3
},
"valid": false,
"schema_id": "oneOf_9_0"
},
{
"description": "extra properties are valid (extensible)",
"data": {
"foo": 1,
"bar": 2,
"extra": "value"
},
"valid": true,
"schema_id": "oneOf_9_0"
}
]
},
{
"description": "oneOf with missing optional property",
"database": {
"schemas": [
{
"oneOf": [
{
"properties": {
"bar": true,
"baz": true
},
"required": [
"bar"
]
},
{
"properties": {
"foo": true
},
"required": [
"foo"
]
}
],
"$id": "oneOf_10_0"
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {
"bar": 8
},
"valid": true,
"schema_id": "oneOf_10_0"
},
{
"description": "second oneOf valid",
"data": {
"foo": "foo"
},
"valid": true,
"schema_id": "oneOf_10_0"
},
{
"description": "both oneOf valid",
"data": {
"foo": "foo",
"bar": 8
},
"valid": false,
"schema_id": "oneOf_10_0"
},
{
"description": "neither oneOf valid",
"data": {
"baz": "quux"
},
"valid": false,
"schema_id": "oneOf_10_0"
}
]
},
{
"description": "nested oneOf, to check validation semantics",
"database": {
"schemas": [
{
"oneOf": [
{
"oneOf": [
{
"type": "null"
}
]
}
],
"$id": "oneOf_11_0"
}
]
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true,
"schema_id": "oneOf_11_0"
},
{
"description": "anything non-null is invalid",
"data": 123,
"valid": false,
"schema_id": "oneOf_11_0"
}
]
},
{
"description": "extensible: true allows extra properties in oneOf",
"database": {
"schemas": [
{
"oneOf": [
{
"properties": {
"bar": {
"type": "integer"
}
},
"required": [
"bar"
]
},
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
}
],
"extensible": true,
"$id": "oneOf_12_0"
}
]
},
"tests": [
{
"description": "extra property is valid (matches first option)",
"data": {
"bar": 2,
"extra": "prop"
},
"valid": true,
"schema_id": "oneOf_12_0"
}
]
}
]