alpha jspg

This commit is contained in:
2026-02-17 22:40:22 -05:00
parent 623c34c0bc
commit 8e50d4852d
58 changed files with 4 additions and 9436 deletions

View File

@ -1,392 +0,0 @@
[
{
"description": "allOf",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{
"properties": {
"bar": {
"type": "integer"
}
},
"required": [
"bar"
]
},
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
}
]
},
"tests": [
{
"description": "allOf",
"data": {
"foo": "baz",
"bar": 2
},
"valid": true
},
{
"description": "mismatch second",
"data": {
"foo": "baz"
},
"valid": false
},
{
"description": "mismatch first",
"data": {
"bar": 2
},
"valid": false
},
{
"description": "wrong type",
"data": {
"foo": "baz",
"bar": "quux"
},
"valid": false
}
]
},
{
"description": "allOf with base schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"bar": {
"type": "integer"
},
"baz": {},
"foo": {
"type": "string"
}
},
"required": [
"bar"
],
"allOf": [
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
},
{
"properties": {
"baz": {
"type": "null"
}
},
"required": [
"baz"
]
}
]
},
"tests": [
{
"description": "valid",
"data": {
"foo": "quux",
"bar": 2,
"baz": null
},
"valid": true
},
{
"description": "mismatch base schema",
"data": {
"foo": "quux",
"baz": null
},
"valid": false
},
{
"description": "mismatch first allOf",
"data": {
"bar": 2,
"baz": null
},
"valid": false
},
{
"description": "mismatch second allOf",
"data": {
"foo": "quux",
"bar": 2
},
"valid": false
},
{
"description": "mismatch both",
"data": {
"bar": 2
},
"valid": false
}
]
},
{
"description": "allOf simple types",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{
"maximum": 30
},
{
"minimum": 20
}
]
},
"tests": [
{
"description": "valid",
"data": 25,
"valid": true
},
{
"description": "mismatch one",
"data": 35,
"valid": false
}
]
},
{
"description": "allOf with boolean schemas, all true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
true,
true
]
},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
},
{
"description": "allOf with boolean schemas, some false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
true,
false
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "allOf with boolean schemas, all false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
false,
false
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "allOf with one empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{}
]
},
"tests": [
{
"description": "any data is valid",
"data": 1,
"valid": true
}
]
},
{
"description": "allOf with two empty schemas",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{},
{}
]
},
"tests": [
{
"description": "any data is valid",
"data": 1,
"valid": true
}
]
},
{
"description": "allOf with the first empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{},
{
"type": "number"
}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "allOf with the last empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{
"type": "number"
},
{}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "nested allOf, to check validation semantics",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{
"allOf": [
{
"type": "null"
}
]
}
]
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "anything non-null is invalid",
"data": 123,
"valid": false
}
]
},
{
"description": "allOf combined with anyOf, oneOf",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{
"multipleOf": 2
}
],
"anyOf": [
{
"multipleOf": 3
}
],
"oneOf": [
{
"multipleOf": 5
}
]
},
"tests": [
{
"description": "allOf: false, anyOf: false, oneOf: false",
"data": 1,
"valid": false
},
{
"description": "allOf: false, anyOf: false, oneOf: true",
"data": 5,
"valid": false
},
{
"description": "allOf: false, anyOf: true, oneOf: false",
"data": 3,
"valid": false
},
{
"description": "allOf: false, anyOf: true, oneOf: true",
"data": 15,
"valid": false
},
{
"description": "allOf: true, anyOf: false, oneOf: false",
"data": 2,
"valid": false
},
{
"description": "allOf: true, anyOf: false, oneOf: true",
"data": 10,
"valid": false
},
{
"description": "allOf: true, anyOf: true, oneOf: false",
"data": 6,
"valid": false
},
{
"description": "allOf: true, anyOf: true, oneOf: true",
"data": 30,
"valid": true
}
]
}
]

View File

@ -1,120 +0,0 @@
[
{
"description": "Location-independent identifier",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$ref": "#foo",
"$defs": {
"A": {
"$anchor": "foo",
"type": "integer"
}
}
},
"tests": [
{
"data": 1,
"description": "match",
"valid": true
},
{
"data": "a",
"description": "mismatch",
"valid": false
}
]
},
{
"description": "Location-independent identifier with absolute URI",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$ref": "http://localhost:1234/draft2020-12/bar#foo",
"$defs": {
"A": {
"$id": "http://localhost:1234/draft2020-12/bar",
"$anchor": "foo",
"type": "integer"
}
}
},
"tests": [
{
"data": 1,
"description": "match",
"valid": true
},
{
"data": "a",
"description": "mismatch",
"valid": false
}
]
},
{
"description": "Location-independent identifier with base URI change in subschema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://localhost:1234/draft2020-12/root",
"$ref": "http://localhost:1234/draft2020-12/nested.json#foo",
"$defs": {
"A": {
"$id": "nested.json",
"$defs": {
"B": {
"$anchor": "foo",
"type": "integer"
}
}
}
}
},
"tests": [
{
"data": 1,
"description": "match",
"valid": true
},
{
"data": "a",
"description": "mismatch",
"valid": false
}
]
},
{
"description": "same $anchor with different base uri",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://localhost:1234/draft2020-12/foobar",
"$defs": {
"A": {
"$id": "child1",
"allOf": [
{
"$id": "child2",
"$anchor": "my_anchor",
"type": "number"
},
{
"$anchor": "my_anchor",
"type": "string"
}
]
}
},
"$ref": "child1#my_anchor"
},
"tests": [
{
"description": "$ref resolves to /$defs/A/allOf/1",
"data": "a",
"valid": true
},
{
"description": "$ref does not resolve to /$defs/A/allOf/0",
"data": 1,
"valid": false
}
]
}
]

View File

@ -1,164 +0,0 @@
[
{
"description": "anyOf with boolean schemas, all true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
true,
true
]
},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
},
{
"description": "anyOf with boolean schemas, some true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
true,
false
]
},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
},
{
"description": "anyOf with boolean schemas, all false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
false,
false
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "anyOf complex types",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"properties": {
"bar": {
"type": "integer"
}
},
"required": [
"bar"
]
},
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
}
]
},
"tests": [
{
"description": "first anyOf valid (complex)",
"data": {
"bar": 2
},
"valid": true
},
{
"description": "second anyOf valid (complex)",
"data": {
"foo": "baz"
},
"valid": true
},
{
"description": "both anyOf valid (complex)",
"data": {
"foo": "baz",
"bar": 2
},
"valid": true
},
{
"description": "neither anyOf valid (complex)",
"data": {
"foo": 2,
"bar": "quux"
},
"valid": false
}
]
},
{
"description": "anyOf with one empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "number"
},
{}
]
},
"tests": [
{
"description": "string is valid",
"data": "foo",
"valid": true
},
{
"description": "number is valid",
"data": 123,
"valid": true
}
]
},
{
"description": "nested anyOf, to check validation semantics",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"anyOf": [
{
"type": "null"
}
]
}
]
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "anything non-null is invalid",
"data": 123,
"valid": false
}
]
}
]

View File

@ -1,104 +0,0 @@
[
{
"description": "boolean schema 'true'",
"schema": true,
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "string is valid",
"data": "foo",
"valid": true
},
{
"description": "boolean true is valid",
"data": true,
"valid": true
},
{
"description": "boolean false is valid",
"data": false,
"valid": true
},
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "object is valid",
"data": {"foo": "bar"},
"valid": true
},
{
"description": "empty object is valid",
"data": {},
"valid": true
},
{
"description": "array is valid",
"data": ["foo"],
"valid": true
},
{
"description": "empty array is valid",
"data": [],
"valid": true
}
]
},
{
"description": "boolean schema 'false'",
"schema": false,
"tests": [
{
"description": "number is invalid",
"data": 1,
"valid": false
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
},
{
"description": "boolean true is invalid",
"data": true,
"valid": false
},
{
"description": "boolean false is invalid",
"data": false,
"valid": false
},
{
"description": "null is invalid",
"data": null,
"valid": false
},
{
"description": "object is invalid",
"data": {"foo": "bar"},
"valid": false
},
{
"description": "empty object is invalid",
"data": {},
"valid": false
},
{
"description": "array is invalid",
"data": ["foo"],
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
}
]

View File

@ -1,62 +0,0 @@
[
{
"description": "handling of non-existent schemas",
"enums": [],
"types": [],
"puncs": [],
"tests": [
{
"description": "validate against non-existent schema",
"schema_id": "non_existent_schema",
"data": {
"foo": "bar"
},
"valid": false,
"expect_errors": [
{
"code": "SCHEMA_NOT_FOUND",
"path": "",
"message_contains": "Schema 'non_existent_schema' not found"
}
]
}
]
},
{
"description": "invalid schema caching",
"enums": [],
"types": [],
"puncs": [
{
"name": "invalid_punc",
"public": false,
"schemas": [
{
"$id": "invalid_punc.request",
"type": [
"invalid_type_value"
]
}
]
}
],
"tests": [
{
"description": "cache returns errors for invalid types",
"action": "cache",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "ENUM_VIOLATED",
"path": ""
},
{
"code": "SCHEMA_PARSE_FAILED",
"path": ""
}
]
}
]
}
]

View File

@ -1,481 +0,0 @@
[
{
"description": "const validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": 2
},
"tests": [
{
"description": "same value is valid",
"data": 2,
"valid": true
},
{
"description": "another value is invalid",
"data": 5,
"valid": false
},
{
"description": "another type is invalid",
"data": "a",
"valid": false
}
]
},
{
"description": "const with object",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": {
"foo": "bar",
"baz": "bax"
}
},
"tests": [
{
"description": "same object is valid",
"data": {},
"valid": true
},
{
"description": "same object with different property order is valid",
"data": {},
"valid": true
},
{
"description": "another object is invalid",
"data": {},
"valid": false
},
{
"description": "another type is invalid",
"data": [
1,
2
],
"valid": false
}
]
},
{
"description": "const with array",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": [
{
"foo": "bar"
}
]
},
"tests": [
{
"description": "same array is valid",
"data": [
{
"foo": "bar"
}
],
"valid": true
},
{
"description": "another array item is invalid",
"data": [
2
],
"valid": false
}
]
},
{
"description": "const with null",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": null
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "not null is invalid",
"data": 0,
"valid": false
}
]
},
{
"description": "const with false does not match 0",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": false
},
"tests": [
{
"description": "false is valid",
"data": false,
"valid": true
},
{
"description": "integer zero is invalid",
"data": 0,
"valid": false
},
{
"description": "float zero is invalid",
"data": 0.0,
"valid": false
}
]
},
{
"description": "const with true does not match 1",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": true
},
"tests": [
{
"description": "true is valid",
"data": true,
"valid": true
},
{
"description": "integer one is invalid",
"data": 1,
"valid": false
},
{
"description": "float one is invalid",
"data": 1.0,
"valid": false
}
]
},
{
"description": "const with [false] does not match [0]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": [
false
]
},
"tests": [
{
"description": "[false] is valid",
"data": [
false
],
"valid": true
},
{
"description": "[0] is invalid",
"data": [
0
],
"valid": false
},
{
"description": "[0.0] is invalid",
"data": [
0.0
],
"valid": false
}
]
},
{
"description": "const with [true] does not match [1]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": [
true
]
},
"tests": [
{
"description": "[true] is valid",
"data": [
true
],
"valid": true
},
{
"description": "[1] is invalid",
"data": [
1
],
"valid": false
},
{
"description": "[1.0] is invalid",
"data": [
1.0
],
"valid": false
}
]
},
{
"description": "const with {\"a\": false} does not match {\"a\": 0}",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": {
"a": false
}
},
"tests": [
{
"description": "{\"a\": false} is valid",
"data": {},
"valid": true
},
{
"description": "{\"a\": 0} is invalid",
"data": {},
"valid": false
},
{
"description": "{\"a\": 0.0} is invalid",
"data": {},
"valid": false
}
]
},
{
"description": "const with {\"a\": true} does not match {\"a\": 1}",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": {
"a": true
}
},
"tests": [
{
"description": "{\"a\": true} is valid",
"data": {},
"valid": true
},
{
"description": "{\"a\": 1} is invalid",
"data": {},
"valid": false
},
{
"description": "{\"a\": 1.0} is invalid",
"data": {},
"valid": false
}
]
},
{
"description": "const with 0 does not match other zero-like types",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": 0
},
"tests": [
{
"description": "false is invalid",
"data": false,
"valid": false
},
{
"description": "integer zero is valid",
"data": 0,
"valid": true
},
{
"description": "float zero is valid",
"data": 0.0,
"valid": true
},
{
"description": "empty object is invalid",
"data": {},
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
},
{
"description": "empty string is invalid",
"data": "",
"valid": false
}
]
},
{
"description": "const with 1 does not match true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": 1
},
"tests": [
{
"description": "true is invalid",
"data": true,
"valid": false
},
{
"description": "integer one is valid",
"data": 1,
"valid": true
},
{
"description": "float one is valid",
"data": 1.0,
"valid": true
}
]
},
{
"description": "const with -2.0 matches integer and float types",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": -2.0
},
"tests": [
{
"description": "integer -2 is valid",
"data": -2,
"valid": true
},
{
"description": "integer 2 is invalid",
"data": 2,
"valid": false
},
{
"description": "float -2.0 is valid",
"data": -2.0,
"valid": true
},
{
"description": "float 2.0 is invalid",
"data": 2.0,
"valid": false
},
{
"description": "float -2.00001 is invalid",
"data": -2.00001,
"valid": false
}
]
},
{
"description": "float and integers are equal up to 64-bit representation limits",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": 9007199254740992
},
"tests": [
{
"description": "integer is valid",
"data": 9007199254740992,
"valid": true
},
{
"description": "integer minus one is invalid",
"data": 9007199254740991,
"valid": false
},
{
"description": "float is valid",
"data": 9007199254740992.0,
"valid": true
},
{
"description": "float minus one is invalid",
"data": 9007199254740991.0,
"valid": false
}
]
},
{
"description": "nul characters in strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": "hello\u0000there"
},
"tests": [
{
"description": "match string with nul",
"data": "hello\u0000there",
"valid": true
},
{
"description": "do not match string lacking nul",
"data": "hellothere",
"valid": false
}
]
},
{
"description": "characters with the same visual representation but different codepoint",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": "\u03bc",
"$comment": "U+03BC"
},
"tests": [
{
"description": "character uses the same codepoint",
"data": "\u03bc",
"comment": "U+03BC",
"valid": true
},
{
"description": "character looks the same but uses a different codepoint",
"data": "\u00b5",
"comment": "U+00B5",
"valid": false
}
]
},
{
"description": "characters with the same visual representation, but different number of codepoints",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": "\u00e4",
"$comment": "U+00E4"
},
"tests": [
{
"description": "character uses the same codepoint",
"data": "\u00e4",
"comment": "U+00E4",
"valid": true
},
{
"description": "character looks the same but uses combining marks",
"data": "a\u0308",
"comment": "a, U+0308",
"valid": false
}
]
},
{
"description": "zero fraction",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": 2
},
"tests": [
{
"description": "with fraction",
"data": 2.0,
"valid": true
},
{
"description": "without fraction",
"data": 2,
"valid": true
}
]
}
]

View File

@ -1,176 +0,0 @@
[
{
"description": "contains keyword validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"minimum": 5}
},
"tests": [
{
"description": "array with item matching schema (5) is valid",
"data": [3, 4, 5],
"valid": true
},
{
"description": "array with item matching schema (6) is valid",
"data": [3, 4, 6],
"valid": true
},
{
"description": "array with two items matching schema (5, 6) is valid",
"data": [3, 4, 5, 6],
"valid": true
},
{
"description": "array without items matching schema is invalid",
"data": [2, 3, 4],
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
},
{
"description": "not array is valid",
"data": {},
"valid": true
}
]
},
{
"description": "contains keyword with const keyword",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "const": 5 }
},
"tests": [
{
"description": "array with item 5 is valid",
"data": [3, 4, 5],
"valid": true
},
{
"description": "array with two items 5 is valid",
"data": [3, 4, 5, 5],
"valid": true
},
{
"description": "array without item 5 is invalid",
"data": [1, 2, 3, 4],
"valid": false
}
]
},
{
"description": "contains keyword with boolean schema true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": true
},
"tests": [
{
"description": "any non-empty array is valid",
"data": ["foo"],
"valid": true
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
},
{
"description": "contains keyword with boolean schema false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": false
},
"tests": [
{
"description": "any non-empty array is invalid",
"data": ["foo"],
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
},
{
"description": "non-arrays are valid",
"data": "contains does not apply to strings",
"valid": true
}
]
},
{
"description": "items + contains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": { "multipleOf": 2 },
"contains": { "multipleOf": 3 }
},
"tests": [
{
"description": "matches items, does not match contains",
"data": [ 2, 4, 8 ],
"valid": false
},
{
"description": "does not match items, matches contains",
"data": [ 3, 6, 9 ],
"valid": false
},
{
"description": "matches both items and contains",
"data": [ 6, 12 ],
"valid": true
},
{
"description": "matches neither items nor contains",
"data": [ 1, 5 ],
"valid": false
}
]
},
{
"description": "contains with false if subschema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {
"if": false,
"else": true
}
},
"tests": [
{
"description": "any non-empty array is valid",
"data": ["foo"],
"valid": true
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
},
{
"description": "contains with null instance elements",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {
"type": "null"
}
},
"tests": [
{
"description": "allows null items",
"data": [ null ],
"valid": true
}
]
}
]

View File

@ -1,121 +0,0 @@
[
{
"description": "validation of string-encoded content based on media type",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json"
},
"tests": [
{
"description": "a valid JSON document",
"data": "{\"foo\": \"bar\"}",
"valid": true
},
{
"description": "an invalid JSON document; validates true",
"data": "{:}",
"valid": true
}
]
},
{
"description": "validation of binary string-encoding",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentEncoding": "base64"
},
"tests": [
{
"description": "a valid base64 string",
"data": "eyJmb28iOiAiYmFyIn0K",
"valid": true
},
{
"description": "an invalid base64 string (% is not a valid character); validates true",
"data": "eyJmb28iOi%iYmFyIn0K",
"valid": true
}
]
},
{
"description": "validation of binary-encoded media type documents",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentEncoding": "base64"
},
"tests": [
{
"description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K",
"valid": true
},
{
"description": "a validly-encoded invalid JSON document; validates true",
"data": "ezp9Cg==",
"valid": true
},
{
"description": "an invalid base64 string that is valid JSON; validates true",
"data": "{}",
"valid": true
}
]
},
{
"description": "validation of binary-encoded media type documents with schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentEncoding": "base64",
"contentSchema": {
"type": "object",
"required": [
"foo"
],
"properties": {
"foo": {
"type": "string"
}
}
}
},
"tests": [
{
"description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K",
"valid": true
},
{
"description": "another valid base64-encoded JSON document",
"data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==",
"valid": true
},
{
"description": "an invalid base64-encoded JSON document; validates true",
"data": "eyJib28iOiAyMH0=",
"valid": true
},
{
"description": "an empty object as a base64-encoded JSON document; validates true",
"data": "e30=",
"valid": true
},
{
"description": "an empty array as a base64-encoded JSON document",
"data": "W10=",
"valid": true
},
{
"description": "a validly-encoded invalid JSON document; validates true",
"data": "ezp9Cg==",
"valid": true
},
{
"description": "an invalid base64 string that is valid JSON; validates true",
"data": "{}",
"valid": true
}
]
}
]

View File

@ -1,82 +0,0 @@
[
{
"description": "invalid type for default",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"foo": {
"type": "integer",
"default": []
}
}
},
"tests": [
{
"description": "valid when property is specified",
"data": {"foo": 13},
"valid": true
},
{
"description": "still valid when the invalid default is used",
"data": {},
"valid": true
}
]
},
{
"description": "invalid string value for default",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"bar": {
"type": "string",
"minLength": 4,
"default": "bad"
}
}
},
"tests": [
{
"description": "valid when property is specified",
"data": {"bar": "good"},
"valid": true
},
{
"description": "still valid when the invalid default is used",
"data": {},
"valid": true
}
]
},
{
"description": "the default keyword does not do anything if the property is missing",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"alpha": {
"type": "number",
"maximum": 3,
"default": 5
}
}
},
"tests": [
{
"description": "an explicit property value is checked against maximum (passing)",
"data": { "alpha": 1 },
"valid": true
},
{
"description": "an explicit property value is checked against maximum (failing)",
"data": { "alpha": 5 },
"valid": false
},
{
"description": "missing properties are not filled in with the default",
"data": {},
"valid": true
}
]
}
]

View File

@ -1,76 +0,0 @@
[
{
"description": "valid definition schema (using $defs)",
"schema": {
"$defs": {
"foo": {
"type": "integer"
}
},
"$ref": "#/$defs/foo"
},
"tests": [
{
"description": "valid definition",
"data": 1,
"valid": true
},
{
"description": "invalid definition",
"data": "a",
"valid": false
}
]
},
{
"description": "valid definition schema (using definitions for compat)",
"schema": {
"definitions": {
"foo": {
"type": "integer"
}
},
"$ref": "#/definitions/foo"
},
"tests": [
{
"description": "valid definition",
"data": 1,
"valid": true
},
{
"description": "invalid definition",
"data": "a",
"valid": false
}
]
},
{
"description": "nested definitions",
"schema": {
"$defs": {
"foo": {
"$defs": {
"bar": {
"type": "string"
}
},
"$ref": "#/$defs/foo/$defs/bar"
}
},
"$ref": "#/$defs/foo"
},
"tests": [
{
"description": "valid nested definition",
"data": "foo",
"valid": true
},
{
"description": "invalid nested definition",
"data": 1,
"valid": false
}
]
}
]

View File

@ -1,325 +0,0 @@
[
{
"description": "basic field dependencies",
"enums": [],
"types": [],
"puncs": [
{
"name": "dependency_split_test",
"public": false,
"schemas": [
{
"$id": "dependency_split_test.request",
"type": "object",
"properties": {
"creating": {
"type": "boolean"
},
"name": {
"type": "string"
},
"kind": {
"type": "string"
},
"description": {
"type": "string"
}
},
"dependencies": {
"creating": [
"name",
"kind"
]
}
}
]
}
],
"tests": [
{
"description": "missing both dependent fields",
"schema_id": "dependency_split_test.request",
"data": {
"creating": true,
"description": "desc"
},
"valid": false,
"expect_errors": [
{
"code": "DEPENDENCY_FAILED",
"path": "/name"
},
{
"code": "DEPENDENCY_FAILED",
"path": "/kind"
}
]
},
{
"description": "missing one dependent field",
"schema_id": "dependency_split_test.request",
"data": {
"creating": true,
"name": "My Account"
},
"valid": false,
"expect_errors": [
{
"code": "DEPENDENCY_FAILED",
"path": "/kind"
}
]
},
{
"description": "no triggering field present",
"schema_id": "dependency_split_test.request",
"data": {
"description": "desc"
},
"valid": true
},
{
"description": "triggering field is false but present - dependencies apply",
"schema_id": "dependency_split_test.request",
"data": {
"creating": false,
"description": "desc"
},
"valid": false,
"expect_errors": [
{
"code": "DEPENDENCY_FAILED",
"path": "/name"
},
{
"code": "DEPENDENCY_FAILED",
"path": "/kind"
}
]
}
]
},
{
"description": "nested dependencies in array items",
"enums": [],
"types": [],
"puncs": [
{
"name": "nested_dep_test",
"public": false,
"schemas": [
{
"$id": "nested_dep_test.request",
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"creating": {
"type": "boolean"
},
"name": {
"type": "string"
},
"kind": {
"type": "string"
}
},
"required": [
"id"
],
"dependencies": {
"creating": [
"name",
"kind"
]
}
}
}
},
"required": [
"items"
]
}
]
}
],
"tests": [
{
"description": "violations in array items",
"schema_id": "nested_dep_test.request",
"data": {
"items": [
{
"id": "item1",
"creating": true
},
{
"id": "item2",
"creating": true,
"name": "Item 2"
}
]
},
"valid": false,
"expect_errors": [
{
"code": "DEPENDENCY_FAILED",
"path": "/items/0/name"
},
{
"code": "DEPENDENCY_FAILED",
"path": "/items/0/kind"
},
{
"code": "DEPENDENCY_FAILED",
"path": "/items/1/kind"
}
]
}
]
},
{
"description": "dependency merging across inheritance",
"enums": [],
"puncs": [],
"types": [
{
"name": "entity",
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"type": "string"
},
"created_by": {
"type": "string",
"format": "uuid"
},
"creating": {
"type": "boolean"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"type",
"created_by"
],
"dependencies": {
"creating": [
"name"
]
}
}
]
},
{
"name": "user",
"schemas": [
{
"$id": "user",
"$ref": "entity",
"properties": {
"password": {
"type": "string",
"minLength": 8
}
},
"dependencies": {
"creating": [
"name"
]
}
}
]
},
{
"name": "person",
"schemas": [
{
"$id": "person",
"$ref": "user",
"properties": {
"first_name": {
"type": "string",
"minLength": 1
},
"last_name": {
"type": "string",
"minLength": 1
}
},
"dependencies": {
"creating": [
"first_name",
"last_name"
]
}
}
]
}
],
"tests": [
{
"description": "merged dependencies across inheritance",
"schema_id": "person",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "person",
"created_by": "550e8400-e29b-41d4-a716-446655440001",
"creating": true,
"password": "securepass"
},
"valid": false,
"expect_errors": [
{
"code": "DEPENDENCY_FAILED",
"path": "/name"
},
{
"code": "DEPENDENCY_FAILED",
"path": "/first_name"
},
{
"code": "DEPENDENCY_FAILED",
"path": "/last_name"
}
]
},
{
"description": "partial dependency satisfaction across inheritance",
"schema_id": "person",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "person",
"created_by": "550e8400-e29b-41d4-a716-446655440001",
"creating": true,
"password": "securepass",
"name": "John Doe",
"first_name": "John"
},
"valid": false,
"expect_errors": [
{
"code": "DEPENDENCY_FAILED",
"path": "/last_name"
}
]
}
]
}
]

View File

@ -1,141 +0,0 @@
[
{
"description": "single dependency",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentRequired": {
"bar": [
"foo"
]
}
},
"tests": [
{
"description": "neither",
"data": {},
"valid": true
},
{
"description": "nondependant",
"data": {},
"valid": true
},
{
"description": "with dependency",
"data": {},
"valid": true
},
{
"description": "missing dependency",
"data": {},
"valid": false
}
]
},
{
"description": "empty dependents",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentRequired": {
"bar": []
}
},
"tests": [
{
"description": "empty object",
"data": {},
"valid": true
},
{
"description": "object with one property",
"data": {},
"valid": true
},
{
"description": "non-object is valid",
"data": 1,
"valid": true
}
]
},
{
"description": "multiple dependents required",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentRequired": {
"quux": [
"foo",
"bar"
]
}
},
"tests": [
{
"description": "neither",
"data": {},
"valid": true
},
{
"description": "nondependants",
"data": {},
"valid": true
},
{
"description": "with dependencies",
"data": {},
"valid": true
},
{
"description": "missing dependency",
"data": {},
"valid": false
},
{
"description": "missing other dependency",
"data": {},
"valid": false
},
{
"description": "missing both dependencies",
"data": {},
"valid": false
}
]
},
{
"description": "dependencies with escaped characters",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentRequired": {
"foo\nbar": [
"foo\rbar"
],
"foo\"bar": [
"foo'bar"
]
}
},
"tests": [
{
"description": "CRLF",
"data": {},
"valid": true
},
{
"description": "quoted quotes",
"data": {},
"valid": true
},
{
"description": "CRLF missing dependent",
"data": {},
"valid": false
},
{
"description": "quoted quotes missing dependent",
"data": {},
"valid": false
}
]
}
]

View File

@ -1,117 +0,0 @@
[
{
"description": "single dependency",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentSchemas": {
"bar": {
"properties": {
"foo": {
"type": "integer"
},
"bar": {
"type": "integer"
}
}
}
}
},
"tests": [
{
"description": "valid",
"data": {},
"valid": true
},
{
"description": "no dependency",
"data": {},
"valid": true
},
{
"description": "wrong type",
"data": {},
"valid": false
},
{
"description": "wrong type other",
"data": {},
"valid": false
},
{
"description": "wrong type both",
"data": {},
"valid": false
}
]
},
{
"description": "boolean subschemas",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentSchemas": {
"foo": true,
"bar": false
}
},
"tests": [
{
"description": "object with property having schema true is valid",
"data": {},
"valid": true
},
{
"description": "object with property having schema false is invalid",
"data": {},
"valid": false
},
{
"description": "object with both properties is invalid",
"data": {},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "dependencies with escaped characters",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentSchemas": {
"foo\tbar": {
"minProperties": 4
},
"foo'bar": {
"required": [
"foo\"bar"
]
}
}
},
"tests": [
{
"description": "quoted tab",
"data": {},
"valid": true
},
{
"description": "quoted quote",
"data": {},
"valid": false
},
{
"description": "quoted tab invalid under dependent schema",
"data": {},
"valid": false
},
{
"description": "quoted quote invalid under dependent schema",
"data": {},
"valid": false
}
]
}
]

View File

@ -1,121 +0,0 @@
[
{
"description": "Simple dynamicRef to dynamicAnchor in same schema",
"schema": {
"$id": "https://test.jspg.org/dynamic-ref/simple",
"$dynamicAnchor": "root",
"type": "array",
"items": {
"$dynamicRef": "#item"
},
"$defs": {
"item": {
"$dynamicAnchor": "item",
"type": "string"
}
}
},
"tests": [
{
"description": "valid string item",
"data": [
"foo"
],
"valid": true
},
{
"description": "invalid number item",
"data": [
1
],
"valid": false
}
]
},
{
"description": "Dynamic scope resolution (generic list pattern)",
"schema": {
"$id": "https://test.jspg.org/dynamic-ref/override",
"$dynamicAnchor": "root",
"$ref": "https://test.jspg.org/dynamic-ref/generic-list",
"$defs": {
"generic-list": {
"$id": "https://test.jspg.org/dynamic-ref/generic-list",
"$dynamicAnchor": "list",
"type": "array",
"items": {
"$dynamicRef": "#item"
},
"$defs": {
"defaultItem": {
"$dynamicAnchor": "item",
"type": "string"
}
}
},
"override-item": {
"$dynamicAnchor": "item",
"type": "integer"
}
}
},
"tests": [
{
"description": "integers valid (overridden)",
"data": [
1,
2
],
"valid": true
},
{
"description": "strings invalid (overridden)",
"data": [
"a"
],
"valid": false
}
]
},
{
"description": "Dynamic scope resolution (no override uses default)",
"schema": {
"$id": "https://test.jspg.org/dynamic-ref/no-override",
"$dynamicAnchor": "root",
"$ref": "https://test.jspg.org/dynamic-ref/generic-list-2",
"$defs": {
"generic-list-2": {
"$id": "https://test.jspg.org/dynamic-ref/generic-list-2",
"$dynamicAnchor": "list",
"type": "array",
"items": {
"$dynamicRef": "#item"
},
"$defs": {
"defaultItem": {
"$dynamicAnchor": "item",
"type": "string"
}
}
}
}
},
"tests": [
{
"description": "strings valid (default)",
"data": [
"a",
"b"
],
"valid": true
},
{
"description": "integers invalid (default)",
"data": [
1
],
"valid": false
}
]
}
]

View File

@ -1,491 +0,0 @@
[
{
"description": "simple enum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
1,
2,
3
]
},
"tests": [
{
"description": "one of the enum is valid",
"data": 1,
"valid": true
},
{
"description": "something else is invalid",
"data": 4,
"valid": false
}
]
},
{
"description": "heterogeneous enum-with-null validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
6,
null
]
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "number is valid",
"data": 6,
"valid": true
},
{
"description": "something else is invalid",
"data": "test",
"valid": false
}
]
},
{
"description": "enums in properties",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"foo": {
"enum": [
"foo"
]
},
"bar": {
"enum": [
"bar"
]
}
},
"required": [
"bar"
]
},
"tests": [
{
"description": "both properties are valid",
"data": {
"foo": "foo",
"bar": "bar"
},
"valid": true
},
{
"description": "wrong foo value",
"data": {
"foo": "foot",
"bar": "bar"
},
"valid": false
},
{
"description": "wrong bar value",
"data": {
"foo": "foo",
"bar": "bart"
},
"valid": false
},
{
"description": "missing optional property is valid",
"data": {
"bar": "bar"
},
"valid": true
},
{
"description": "missing required property is invalid",
"data": {
"foo": "foo"
},
"valid": false
},
{
"description": "missing all properties is invalid",
"data": {},
"valid": false
}
]
},
{
"description": "enum with escaped characters",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
"foo\nbar",
"foo\rbar"
]
},
"tests": [
{
"description": "member 1 is valid",
"data": "foo\nbar",
"valid": true
},
{
"description": "member 2 is valid",
"data": "foo\rbar",
"valid": true
},
{
"description": "another string is invalid",
"data": "abc",
"valid": false
}
]
},
{
"description": "enum with false does not match 0",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
false
]
},
"tests": [
{
"description": "false is valid",
"data": false,
"valid": true
},
{
"description": "integer zero is invalid",
"data": 0,
"valid": false
},
{
"description": "float zero is invalid",
"data": 0.0,
"valid": false
}
]
},
{
"description": "enum with [false] does not match [0]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
[
false
]
]
},
"tests": [
{
"description": "[false] is valid",
"data": [
false
],
"valid": true
},
{
"description": "[0] is invalid",
"data": [
0
],
"valid": false
},
{
"description": "[0.0] is invalid",
"data": [
0.0
],
"valid": false
}
]
},
{
"description": "enum with true does not match 1",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
true
]
},
"tests": [
{
"description": "true is valid",
"data": true,
"valid": true
},
{
"description": "integer one is invalid",
"data": 1,
"valid": false
},
{
"description": "float one is invalid",
"data": 1.0,
"valid": false
}
]
},
{
"description": "enum with [true] does not match [1]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
[
true
]
]
},
"tests": [
{
"description": "[true] is valid",
"data": [
true
],
"valid": true
},
{
"description": "[1] is invalid",
"data": [
1
],
"valid": false
},
{
"description": "[1.0] is invalid",
"data": [
1.0
],
"valid": false
}
]
},
{
"description": "enum with 0 does not match false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
0
]
},
"tests": [
{
"description": "false is invalid",
"data": false,
"valid": false
},
{
"description": "integer zero is valid",
"data": 0,
"valid": true
},
{
"description": "float zero is valid",
"data": 0.0,
"valid": true
}
]
},
{
"description": "enum with [0] does not match [false]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
[
0
]
]
},
"tests": [
{
"description": "[false] is invalid",
"data": [
false
],
"valid": false
},
{
"description": "[0] is valid",
"data": [
0
],
"valid": true
},
{
"description": "[0.0] is valid",
"data": [
0.0
],
"valid": true
}
]
},
{
"description": "enum with 1 does not match true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
1
]
},
"tests": [
{
"description": "true is invalid",
"data": true,
"valid": false
},
{
"description": "integer one is valid",
"data": 1,
"valid": true
},
{
"description": "float one is valid",
"data": 1.0,
"valid": true
}
]
},
{
"description": "enum with [1] does not match [true]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
[
1
]
]
},
"tests": [
{
"description": "[true] is invalid",
"data": [
true
],
"valid": false
},
{
"description": "[1] is valid",
"data": [
1
],
"valid": true
},
{
"description": "[1.0] is valid",
"data": [
1.0
],
"valid": true
}
]
},
{
"description": "nul characters in strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [
"hello\u0000there"
]
},
"tests": [
{
"description": "match string with nul",
"data": "hello\u0000there",
"valid": true
},
{
"description": "do not match string lacking nul",
"data": "hellothere",
"valid": false
}
]
},
{
"description": "enum schema validation",
"enums": [
{
"name": "task_priority",
"values": [
"low",
"medium",
"high",
"urgent"
],
"schemas": [
{
"$id": "task_priority",
"type": "string",
"enum": [
"low",
"medium",
"high",
"urgent"
]
}
]
}
],
"types": [],
"puncs": [
{
"name": "enum_test_punc",
"public": false,
"schemas": [
{
"$id": "enum_test_punc.request",
"type": "object",
"properties": {
"priority": {
"$ref": "task_priority"
}
},
"required": [
"priority"
]
}
]
}
],
"tests": [
{
"description": "valid enum value",
"schema_id": "enum_test_punc.request",
"data": {
"priority": "high"
},
"valid": true
},
{
"description": "invalid enum value",
"schema_id": "enum_test_punc.request",
"data": {
"priority": "critical"
},
"valid": false,
"expect_errors": [
{
"code": "ENUM_VIOLATED",
"path": "/priority",
"context": "critical"
}
]
},
{
"description": "missing required enum field",
"schema_id": "enum_test_punc.request",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/priority"
}
]
}
]
}
]

View File

@ -1,62 +0,0 @@
[
{
"description": "detailed error reporting",
"enums": [],
"types": [],
"puncs": [
{
"name": "detailed_errors_test",
"public": false,
"schemas": [
{
"$id": "detailed_errors_test.request",
"type": "object",
"properties": {
"address": {
"type": "object",
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string",
"maxLength": 10
}
},
"required": [
"street",
"city"
]
}
},
"required": [
"address"
]
}
]
}
],
"tests": [
{
"description": "multiple errors in nested object",
"data": {
"address": {
"street": 123,
"city": "Supercalifragilisticexpialidocious"
}
},
"valid": false,
"expect_errors": [
{
"code": "TYPE_MISMATCH",
"path": "/address/street"
},
{
"code": "MAX_LENGTH_VIOLATED",
"path": "/address/city"
}
]
}
]
}
]

View File

@ -1,26 +0,0 @@
[
{
"description": "exclusiveMaximum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"exclusiveMaximum": 3.0
},
"tests": [
{
"description": "below the exclusiveMaximum is valid",
"data": 2.2,
"valid": true
},
{
"description": "boundary point is invalid",
"data": 3.0,
"valid": false
},
{
"description": "above the exclusiveMaximum is invalid",
"data": 3.5,
"valid": false
}
]
}
]

View File

@ -1,26 +0,0 @@
[
{
"description": "exclusiveMinimum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"exclusiveMinimum": 1.1
},
"tests": [
{
"description": "above the exclusiveMinimum is valid",
"data": 1.2,
"valid": true
},
{
"description": "boundary point is invalid",
"data": 1.1,
"valid": false
},
{
"description": "below the exclusiveMinimum is invalid",
"data": 0.6,
"valid": false
}
]
}
]

View File

@ -1,307 +0,0 @@
[
{
"description": "[content.json] validation of string-encoded content based on media type",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json"
},
"tests": []
},
{
"description": "[content.json] validation of binary string-encoding",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentEncoding": "base64"
},
"tests": []
},
{
"description": "[content.json] validation of binary-encoded media type documents",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentEncoding": "base64"
},
"tests": []
},
{
"description": "[content.json] validation of binary-encoded media type documents with schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentEncoding": "base64",
"contentSchema": {
"type": "object",
"required": [
"foo"
],
"properties": {
"foo": {
"type": "string"
}
}
}
},
"tests": []
},
{
"description": "[uniqueItems.json] uniqueItems with an array of items",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [
{
"type": "boolean"
},
{
"type": "boolean"
}
],
"uniqueItems": true
},
"tests": []
},
{
"description": "[uniqueItems.json] uniqueItems=false with an array of items",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [
{
"type": "boolean"
},
{
"type": "boolean"
}
],
"uniqueItems": false
},
"tests": []
},
{
"description": "[minItems.json] minItems validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minItems": 1
},
"tests": []
},
{
"description": "[exclusiveMinimum.json] exclusiveMinimum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"exclusiveMinimum": 1.1
},
"tests": []
},
{
"description": "[const.json] const with array",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": [
{
"foo": "bar"
}
]
},
"tests": []
},
{
"description": "[punc.json] punc-specific resolution and local refs",
"schema": null,
"tests": []
},
{
"description": "[propertyNames.json] propertyNames validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {
"maxLength": 3
}
},
"tests": []
},
{
"description": "[not.json] collect annotations inside a 'not', even if collection is disabled",
"schema": null,
"tests": []
},
{
"description": "[items.json] non-array instances are valid",
"schema": null,
"tests": []
},
{
"description": "[items.json] Evaluated items collection needs to consider instance location",
"schema": null,
"tests": []
},
{
"description": "[minProperties.json] minProperties validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minProperties": 1
},
"tests": []
},
{
"description": "[properties.json] properties whose names are Javascript object property names",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"__proto__": {
"type": "number"
},
"toString": {
"properties": {
"length": {
"type": "string"
}
}
},
"constructor": {
"type": "number"
}
}
},
"tests": []
},
{
"description": "[maxLength.json] maxLength validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxLength": 2
},
"tests": []
},
{
"description": "[dependentSchemas.json] single dependency",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentSchemas": {
"bar": {
"properties": {
"foo": {
"type": "integer"
},
"bar": {
"type": "integer"
}
}
}
}
},
"tests": []
},
{
"description": "[dependentSchemas.json] dependent subschema incompatible with root",
"schema": null,
"tests": []
},
{
"description": "[exclusiveMaximum.json] exclusiveMaximum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"exclusiveMaximum": 3.0
},
"tests": []
},
{
"description": "[minimum.json] minimum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minimum": 1.1
},
"tests": []
},
{
"description": "[minimum.json] minimum validation with signed integer",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minimum": -2
},
"tests": []
},
{
"description": "[pattern.json] pattern validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"pattern": "^a*$"
},
"tests": []
},
{
"description": "[maxProperties.json] maxProperties validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxProperties": 2
},
"tests": []
},
{
"description": "[dependentRequired.json] single dependency",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentRequired": {
"bar": [
"foo"
]
}
},
"tests": []
},
{
"description": "[required.json] required properties whose names are Javascript object property names",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"__proto__",
"toString",
"constructor"
]
},
"tests": []
},
{
"description": "[multipleOf.json] by int",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"multipleOf": 2
},
"tests": []
},
{
"description": "[patternProperties.json] patternProperties validates properties matching a regex",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": {
"f.*o": {
"type": "integer"
}
}
},
"tests": []
},
{
"description": "[maximum.json] maximum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maximum": 3.0
},
"tests": []
},
{
"description": "[minLength.json] minLength validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minLength": 2
},
"tests": []
},
{
"description": "[maxItems.json] maxItems validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxItems": 2
},
"tests": []
}
]

View File

@ -1 +0,0 @@
[]

View File

@ -1,324 +0,0 @@
[
{
"description": "ignore if without then or else",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": {
"const": 0
}
},
"tests": [
{
"description": "valid when valid against lone if",
"data": 0,
"valid": true
},
{
"description": "valid when invalid against lone if",
"data": "hello",
"valid": true
}
]
},
{
"description": "ignore then without if",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"then": {
"const": 0
}
},
"tests": [
{
"description": "valid when valid against lone then",
"data": 0,
"valid": true
},
{
"description": "valid when invalid against lone then",
"data": "hello",
"valid": true
}
]
},
{
"description": "ignore else without if",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"else": {
"const": 0
}
},
"tests": [
{
"description": "valid when valid against lone else",
"data": 0,
"valid": true
},
{
"description": "valid when invalid against lone else",
"data": "hello",
"valid": true
}
]
},
{
"description": "if and then without else",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": {
"exclusiveMaximum": 0
},
"then": {
"minimum": -10
}
},
"tests": [
{
"description": "valid through then",
"data": -1,
"valid": true
},
{
"description": "invalid through then",
"data": -100,
"valid": false
},
{
"description": "valid when if test fails",
"data": 3,
"valid": true
}
]
},
{
"description": "if and else without then",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": {
"exclusiveMaximum": 0
},
"else": {
"multipleOf": 2
}
},
"tests": [
{
"description": "valid when if test passes",
"data": -1,
"valid": true
},
{
"description": "valid through else",
"data": 4,
"valid": true
},
{
"description": "invalid through else",
"data": 3,
"valid": false
}
]
},
{
"description": "validate against correct branch, then vs else",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": {
"exclusiveMaximum": 0
},
"then": {
"minimum": -10
},
"else": {
"multipleOf": 2
}
},
"tests": [
{
"description": "valid through then",
"data": -1,
"valid": true
},
{
"description": "invalid through then",
"data": -100,
"valid": false
},
{
"description": "valid through else",
"data": 4,
"valid": true
},
{
"description": "invalid through else",
"data": 3,
"valid": false
}
]
},
{
"description": "non-interference across combined schemas",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{
"if": {
"exclusiveMaximum": 0
}
},
{
"then": {
"minimum": -10
}
},
{
"else": {
"multipleOf": 2
}
}
]
},
"tests": [
{
"description": "valid, but would have been invalid through then",
"data": -100,
"valid": true
},
{
"description": "valid, but would have been invalid through else",
"data": 3,
"valid": true
}
]
},
{
"description": "if with boolean schema true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": true,
"then": {
"const": "then"
},
"else": {
"const": "else"
}
},
"tests": [
{
"description": "boolean schema true in if always chooses the then path (valid)",
"data": "then",
"valid": true
},
{
"description": "boolean schema true in if always chooses the then path (invalid)",
"data": "else",
"valid": false
}
]
},
{
"description": "if with boolean schema false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": false,
"then": {
"const": "then"
},
"else": {
"const": "else"
}
},
"tests": [
{
"description": "boolean schema false in if always chooses the else path (invalid)",
"data": "then",
"valid": false
},
{
"description": "boolean schema false in if always chooses the else path (valid)",
"data": "else",
"valid": true
}
]
},
{
"description": "if appears at the end when serialized (keyword processing sequence)",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"then": {
"const": "yes"
},
"else": {
"const": "other"
},
"if": {
"maxLength": 4
}
},
"tests": [
{
"description": "yes redirects to then and passes",
"data": "yes",
"valid": true
},
{
"description": "other redirects to else and passes",
"data": "other",
"valid": true
},
{
"description": "no redirects to then and fails",
"data": "no",
"valid": false
},
{
"description": "invalid redirects to else and fails",
"data": "invalid",
"valid": false
}
]
},
{
"description": "then: false fails when condition matches",
"schema": {
"if": {
"const": 1
},
"then": false
},
"tests": [
{
"description": "matches if \u2192 then=false \u2192 invalid",
"data": 1,
"valid": false
},
{
"description": "does not match if \u2192 then ignored \u2192 valid",
"data": 2,
"valid": true
}
]
},
{
"description": "else: false fails when condition does not match",
"schema": {
"if": {
"const": 1
},
"else": false
},
"tests": [
{
"description": "matches if \u2192 else ignored \u2192 valid",
"data": 1,
"valid": true
},
{
"description": "does not match if \u2192 else executes \u2192 invalid",
"data": 2,
"valid": false
}
]
}
]

View File

@ -1,81 +0,0 @@
[
{
"description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"int": {
"type": "integer"
}
},
"allOf": [
{
"properties": {
"foo": {
"$ref": "#/$defs/int"
}
}
},
{
"additionalProperties": {
"$ref": "#/$defs/int"
}
}
]
},
"tests": [
{
"description": "passing case",
"data": {
"foo": 1
},
"valid": true
},
{
"description": "failing case",
"data": {
"foo": "a string"
},
"valid": false
}
]
},
{
"description": "guard against infinite recursion",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"alice": {
"$anchor": "alice",
"allOf": [
{
"$ref": "#bob"
}
]
},
"bob": {
"$anchor": "bob",
"allOf": [
{
"$ref": "#alice"
}
]
}
},
"$ref": "#alice"
},
"tests": [
{
"description": "infinite recursion detected",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "MAX_DEPTH_REACHED",
"path": ""
}
]
}
]
}
]

View File

@ -1,318 +0,0 @@
[
{
"description": "items with boolean schema (false)",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": false
},
"tests": [
{
"description": "any non-empty array is invalid",
"data": [
1,
"foo",
true
],
"valid": false
},
{
"description": "empty array is valid",
"data": [],
"valid": true
}
]
},
{
"description": "items and subitems",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"item": {
"type": "array",
"items": false,
"prefixItems": [
{
"$ref": "#/$defs/sub-item"
},
{
"$ref": "#/$defs/sub-item"
}
]
},
"sub-item": {
"type": "object",
"required": [
"foo"
]
}
},
"type": "array",
"items": false,
"prefixItems": [
{
"$ref": "#/$defs/item"
},
{
"$ref": "#/$defs/item"
},
{
"$ref": "#/$defs/item"
}
]
},
"tests": [
{
"description": "valid items",
"data": [
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
]
],
"valid": true
},
{
"description": "too many items",
"data": [
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
]
],
"valid": false
},
{
"description": "too many sub-items",
"data": [
[
{
"foo": null
},
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
]
],
"valid": false
},
{
"description": "wrong item",
"data": [
{
"foo": null
},
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
]
],
"valid": false
},
{
"description": "wrong sub-item",
"data": [
[
{},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
],
[
{
"foo": null
},
{
"foo": null
}
]
],
"valid": false
},
{
"description": "fewer items is valid",
"data": [
[
{
"foo": null
}
],
[
{
"foo": null
}
]
],
"valid": true
}
]
},
{
"description": "items does not look in applicators, valid case",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{
"prefixItems": [
{
"minimum": 3
}
]
}
],
"items": {
"minimum": 5
}
},
"tests": [
{
"description": "prefixItems in allOf does not constrain items, invalid case",
"data": [
3,
5
],
"valid": false
},
{
"description": "prefixItems in allOf does not constrain items, valid case",
"data": [
5,
5
],
"valid": true
}
]
},
{
"description": "items with heterogeneous array",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [
{}
],
"items": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [
"foo",
"bar",
37
],
"valid": false
},
{
"description": "valid instance",
"data": [
null
],
"valid": true
}
]
},
{
"description": "items with null instance elements",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": {
"type": "null"
}
},
"tests": [
{
"description": "allows null elements",
"data": [
null
],
"valid": true
}
]
}
]

View File

@ -1,102 +0,0 @@
[
{
"description": "maxContains without contains is ignored",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxContains": 1
},
"tests": [
{
"description": "one item valid against lone maxContains",
"data": [ 1 ],
"valid": true
},
{
"description": "two items still valid against lone maxContains",
"data": [ 1, 2 ],
"valid": true
}
]
},
{
"description": "maxContains with contains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"maxContains": 1
},
"tests": [
{
"description": "empty data",
"data": [ ],
"valid": false
},
{
"description": "all elements match, valid maxContains",
"data": [ 1 ],
"valid": true
},
{
"description": "all elements match, invalid maxContains",
"data": [ 1, 1 ],
"valid": false
},
{
"description": "some elements match, valid maxContains",
"data": [ 1, 2 ],
"valid": true
},
{
"description": "some elements match, invalid maxContains",
"data": [ 1, 2, 1 ],
"valid": false
}
]
},
{
"description": "maxContains with contains, value with a decimal",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"maxContains": 1.0
},
"tests": [
{
"description": "one element matches, valid maxContains",
"data": [ 1 ],
"valid": true
},
{
"description": "too many elements match, invalid maxContains",
"data": [ 1, 1 ],
"valid": false
}
]
},
{
"description": "minContains < maxContains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"minContains": 1,
"maxContains": 3
},
"tests": [
{
"description": "actual < minContains < maxContains",
"data": [ ],
"valid": false
},
{
"description": "minContains < actual < maxContains",
"data": [ 1, 1 ],
"valid": true
},
{
"description": "minContains < maxContains < actual",
"data": [ 1, 1, 1, 1 ],
"valid": false
}
]
}
]

View File

@ -1,60 +0,0 @@
[
{
"description": "maxItems validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxItems": 2
},
"tests": [
{
"description": "shorter is valid",
"data": [
1
],
"valid": true
},
{
"description": "exact length is valid",
"data": [
1,
2
],
"valid": true
},
{
"description": "too long is invalid",
"data": [
1,
2,
3
],
"valid": false
}
]
},
{
"description": "maxItems validation with a decimal",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxItems": 2.0
},
"tests": [
{
"description": "shorter is valid",
"data": [
1
],
"valid": true
},
{
"description": "too long is invalid",
"data": [
1,
2,
3
],
"valid": false
}
]
}
]

View File

@ -1,50 +0,0 @@
[
{
"description": "maxLength validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxLength": 2
},
"tests": [
{
"description": "shorter is valid",
"data": "f",
"valid": true
},
{
"description": "exact length is valid",
"data": "fo",
"valid": true
},
{
"description": "too long is invalid",
"data": "foo",
"valid": false
},
{
"description": "two graphemes is long enough",
"data": "\ud83d\udca9\ud83d\udca9",
"valid": true
}
]
},
{
"description": "maxLength validation with a decimal",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxLength": 2.0
},
"tests": [
{
"description": "shorter is valid",
"data": "f",
"valid": true
},
{
"description": "too long is invalid",
"data": "foo",
"valid": false
}
]
}
]

View File

@ -1,64 +0,0 @@
[
{
"description": "maxProperties validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxProperties": 2
},
"tests": [
{
"description": "shorter is valid",
"data": {},
"valid": true
},
{
"description": "exact length is valid",
"data": {},
"valid": true
},
{
"description": "too long is invalid",
"data": {},
"valid": false
}
]
},
{
"description": "maxProperties validation with a decimal",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxProperties": 2.0
},
"tests": [
{
"description": "shorter is valid",
"data": {},
"valid": true
},
{
"description": "too long is invalid",
"data": {},
"valid": false
}
]
},
{
"description": "maxProperties = 0 means the object is empty",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxProperties": 0
},
"tests": [
{
"description": "no properties is valid",
"data": {},
"valid": true
},
{
"description": "one property is invalid",
"data": {},
"valid": false
}
]
}
]

View File

@ -1,55 +0,0 @@
[
{
"description": "maximum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maximum": 3.0
},
"tests": [
{
"description": "below the maximum is valid",
"data": 2.6,
"valid": true
},
{
"description": "boundary point is valid",
"data": 3.0,
"valid": true
},
{
"description": "above the maximum is invalid",
"data": 3.5,
"valid": false
}
]
},
{
"description": "maximum validation with unsigned integer",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maximum": 300
},
"tests": [
{
"description": "below the maximum is invalid",
"data": 299.97,
"valid": true
},
{
"description": "boundary point integer is valid",
"data": 300,
"valid": true
},
{
"description": "boundary point float is valid",
"data": 300.0,
"valid": true
},
{
"description": "above the maximum is invalid",
"data": 300.5,
"valid": false
}
]
}
]

View File

@ -1,224 +0,0 @@
[
{
"description": "minContains without contains is ignored",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minContains": 1
},
"tests": [
{
"description": "one item valid against lone minContains",
"data": [ 1 ],
"valid": true
},
{
"description": "zero items still valid against lone minContains",
"data": [],
"valid": true
}
]
},
{
"description": "minContains=1 with contains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"minContains": 1
},
"tests": [
{
"description": "empty data",
"data": [ ],
"valid": false
},
{
"description": "no elements match",
"data": [ 2 ],
"valid": false
},
{
"description": "single element matches, valid minContains",
"data": [ 1 ],
"valid": true
},
{
"description": "some elements match, valid minContains",
"data": [ 1, 2 ],
"valid": true
},
{
"description": "all elements match, valid minContains",
"data": [ 1, 1 ],
"valid": true
}
]
},
{
"description": "minContains=2 with contains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"minContains": 2
},
"tests": [
{
"description": "empty data",
"data": [ ],
"valid": false
},
{
"description": "all elements match, invalid minContains",
"data": [ 1 ],
"valid": false
},
{
"description": "some elements match, invalid minContains",
"data": [ 1, 2 ],
"valid": false
},
{
"description": "all elements match, valid minContains (exactly as needed)",
"data": [ 1, 1 ],
"valid": true
},
{
"description": "all elements match, valid minContains (more than needed)",
"data": [ 1, 1, 1 ],
"valid": true
},
{
"description": "some elements match, valid minContains",
"data": [ 1, 2, 1 ],
"valid": true
}
]
},
{
"description": "minContains=2 with contains with a decimal value",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"minContains": 2.0
},
"tests": [
{
"description": "one element matches, invalid minContains",
"data": [ 1 ],
"valid": false
},
{
"description": "both elements match, valid minContains",
"data": [ 1, 1 ],
"valid": true
}
]
},
{
"description": "maxContains = minContains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"maxContains": 2,
"minContains": 2
},
"tests": [
{
"description": "empty data",
"data": [ ],
"valid": false
},
{
"description": "all elements match, invalid minContains",
"data": [ 1 ],
"valid": false
},
{
"description": "all elements match, invalid maxContains",
"data": [ 1, 1, 1 ],
"valid": false
},
{
"description": "all elements match, valid maxContains and minContains",
"data": [ 1, 1 ],
"valid": true
}
]
},
{
"description": "maxContains < minContains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"maxContains": 1,
"minContains": 3
},
"tests": [
{
"description": "empty data",
"data": [ ],
"valid": false
},
{
"description": "invalid minContains",
"data": [ 1 ],
"valid": false
},
{
"description": "invalid maxContains",
"data": [ 1, 1, 1 ],
"valid": false
},
{
"description": "invalid maxContains and minContains",
"data": [ 1, 1 ],
"valid": false
}
]
},
{
"description": "minContains = 0",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"minContains": 0
},
"tests": [
{
"description": "empty data",
"data": [ ],
"valid": true
},
{
"description": "minContains = 0 makes contains always pass",
"data": [ 2 ],
"valid": true
}
]
},
{
"description": "minContains = 0 with maxContains",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": {"const": 1},
"minContains": 0,
"maxContains": 1
},
"tests": [
{
"description": "empty data",
"data": [ ],
"valid": true
},
{
"description": "not more than maxContains",
"data": [ 1 ],
"valid": true
},
{
"description": "too many",
"data": [ 1, 1 ],
"valid": false
}
]
}
]

View File

@ -1,53 +0,0 @@
[
{
"description": "minItems validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minItems": 1
},
"tests": [
{
"description": "longer is valid",
"data": [
1,
2
],
"valid": true
},
{
"description": "exact length is valid",
"data": [
1
],
"valid": true
},
{
"description": "too short is invalid",
"data": [],
"valid": false
}
]
},
{
"description": "minItems validation with a decimal",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minItems": 1.0
},
"tests": [
{
"description": "longer is valid",
"data": [
1,
2
],
"valid": true
},
{
"description": "too short is invalid",
"data": [],
"valid": false
}
]
}
]

View File

@ -1,50 +0,0 @@
[
{
"description": "minLength validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minLength": 2
},
"tests": [
{
"description": "longer is valid",
"data": "foo",
"valid": true
},
{
"description": "exact length is valid",
"data": "fo",
"valid": true
},
{
"description": "too short is invalid",
"data": "f",
"valid": false
},
{
"description": "one grapheme is not long enough",
"data": "\ud83d\udca9",
"valid": false
}
]
},
{
"description": "minLength validation with a decimal",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minLength": 2.0
},
"tests": [
{
"description": "longer is valid",
"data": "foo",
"valid": true
},
{
"description": "too short is invalid",
"data": "f",
"valid": false
}
]
}
]

View File

@ -1,45 +0,0 @@
[
{
"description": "minProperties validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minProperties": 1
},
"tests": [
{
"description": "longer is valid",
"data": {},
"valid": true
},
{
"description": "exact length is valid",
"data": {},
"valid": true
},
{
"description": "too short is invalid",
"data": {},
"valid": false
}
]
},
{
"description": "minProperties validation with a decimal",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minProperties": 1.0
},
"tests": [
{
"description": "longer is valid",
"data": {},
"valid": true
},
{
"description": "too short is invalid",
"data": {},
"valid": false
}
]
}
]

View File

@ -1,65 +0,0 @@
[
{
"description": "minimum validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minimum": 1.1
},
"tests": [
{
"description": "above the minimum is valid",
"data": 2.6,
"valid": true
},
{
"description": "boundary point is valid",
"data": 1.1,
"valid": true
},
{
"description": "below the minimum is invalid",
"data": 0.6,
"valid": false
}
]
},
{
"description": "minimum validation with signed integer",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minimum": -2
},
"tests": [
{
"description": "negative above the minimum is valid",
"data": -1,
"valid": true
},
{
"description": "positive above the minimum is valid",
"data": 0,
"valid": true
},
{
"description": "boundary point is valid",
"data": -2,
"valid": true
},
{
"description": "boundary point with float is valid",
"data": -2.0,
"valid": true
},
{
"description": "float below the minimum is invalid",
"data": -2.0001,
"valid": false
},
{
"description": "int below the minimum is invalid",
"data": -3,
"valid": false
}
]
}
]

View File

@ -1,94 +0,0 @@
[
{
"description": "by int",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"multipleOf": 2
},
"tests": [
{
"description": "int by int",
"data": 10,
"valid": true
},
{
"description": "int by int fail",
"data": 7,
"valid": false
}
]
},
{
"description": "by number",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"multipleOf": 1.5
},
"tests": [
{
"description": "zero is multiple of anything",
"data": 0,
"valid": true
},
{
"description": "4.5 is multiple of 1.5",
"data": 4.5,
"valid": true
},
{
"description": "35 is not multiple of 1.5",
"data": 35,
"valid": false
}
]
},
{
"description": "by small number",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"multipleOf": 0.0001
},
"tests": [
{
"description": "0.0075 is multiple of 0.0001",
"data": 0.0075,
"valid": true
},
{
"description": "0.00751 is not multiple of 0.0001",
"data": 0.00751,
"valid": false
}
]
},
{
"description": "float division = inf",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "integer",
"multipleOf": 0.123456789
},
"tests": [
{
"description": "always invalid, but naive implementations may raise an overflow error",
"data": 1e+308,
"valid": false
}
]
},
{
"description": "small multiple of large integer",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "integer",
"multipleOf": 1e-08
},
"tests": [
{
"description": "any integer is a multiple of 1e-8",
"data": 12391239123,
"valid": true
}
]
}
]

View File

@ -1,302 +0,0 @@
[
{
"description": "not",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": {
"type": "integer"
}
},
"tests": [
{
"description": "allowed",
"data": "foo",
"valid": true
},
{
"description": "disallowed",
"data": 1,
"valid": false
}
]
},
{
"description": "not multiple types",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": {
"type": [
"integer",
"boolean"
]
}
},
"tests": [
{
"description": "valid",
"data": "foo",
"valid": true
},
{
"description": "mismatch",
"data": 1,
"valid": false
},
{
"description": "other mismatch",
"data": true,
"valid": false
}
]
},
{
"description": "not more complex schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
},
"tests": [
{
"description": "match",
"data": 1,
"valid": true
},
{
"description": "other match",
"data": {},
"valid": true
},
{
"description": "mismatch",
"data": {},
"valid": false
}
]
},
{
"description": "forbidden property",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"foo": {
"not": {}
},
"baz": {
"type": "integer"
},
"bar": {
"type": "integer"
}
}
},
"tests": [
{
"description": "property present",
"data": {
"foo": 1,
"bar": 2
},
"valid": false
},
{
"description": "property absent",
"data": {
"bar": 1,
"baz": 2
},
"valid": true
}
]
},
{
"description": "forbid everything with empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": {}
},
"tests": [
{
"description": "number is invalid",
"data": 1,
"valid": false
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
},
{
"description": "boolean true is invalid",
"data": true,
"valid": false
},
{
"description": "boolean false is invalid",
"data": false,
"valid": false
},
{
"description": "null is invalid",
"data": null,
"valid": false
},
{
"description": "object is invalid",
"data": {},
"valid": false
},
{
"description": "empty object is invalid",
"data": {},
"valid": false
},
{
"description": "array is invalid",
"data": [
"foo"
],
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
},
{
"description": "forbid everything with boolean schema true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": true
},
"tests": [
{
"description": "number is invalid",
"data": 1,
"valid": false
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
},
{
"description": "boolean true is invalid",
"data": true,
"valid": false
},
{
"description": "boolean false is invalid",
"data": false,
"valid": false
},
{
"description": "null is invalid",
"data": null,
"valid": false
},
{
"description": "object is invalid",
"data": {},
"valid": false
},
{
"description": "empty object is invalid",
"data": {},
"valid": false
},
{
"description": "array is invalid",
"data": [
"foo"
],
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
},
{
"description": "allow everything with boolean schema false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": false
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "string is valid",
"data": "foo",
"valid": true
},
{
"description": "boolean true is valid",
"data": true,
"valid": true
},
{
"description": "boolean false is valid",
"data": false,
"valid": true
},
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "object is valid",
"data": {},
"valid": true
},
{
"description": "empty object is valid",
"data": {},
"valid": true
},
{
"description": "array is valid",
"data": [
"foo"
],
"valid": true
},
{
"description": "empty array is valid",
"data": [],
"valid": true
}
]
},
{
"description": "double negation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": {
"not": {}
}
},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
}
]

View File

@ -1,296 +0,0 @@
[
{
"description": "oneOf with boolean schemas, all true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
true,
true,
true
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "oneOf with boolean schemas, one true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
true,
false,
false
]
},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
},
{
"description": "oneOf with boolean schemas, more than one true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
true,
true,
false
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "oneOf with boolean schemas, all false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
false,
false,
false
]
},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "oneOf complex types",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"properties": {
"bar": {
"type": "integer"
}
},
"required": [
"bar"
]
},
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
}
]
},
"tests": [
{
"description": "first oneOf valid (complex)",
"data": {
"bar": 2
},
"valid": true
},
{
"description": "second oneOf valid (complex)",
"data": {
"foo": "baz"
},
"valid": true
},
{
"description": "both oneOf valid (complex)",
"data": {
"foo": "baz",
"bar": 2
},
"valid": false
},
{
"description": "neither oneOf valid (complex)",
"data": {
"foo": 2,
"bar": "quux"
},
"valid": false
}
]
},
{
"description": "oneOf with empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"type": "number"
},
{}
]
},
"tests": [
{
"description": "one valid - valid",
"data": "foo",
"valid": true
},
{
"description": "both valid - invalid",
"data": 123,
"valid": false
}
]
},
{
"description": "oneOf with required",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"oneOf": [
{
"required": [
"foo",
"bar"
]
},
{
"required": [
"foo",
"baz"
]
}
]
},
"tests": [
{
"description": "both invalid - invalid",
"data": {
"bar": 2
},
"valid": false
},
{
"description": "first valid - valid",
"data": {
"foo": 1,
"bar": 2
},
"valid": true
},
{
"description": "second valid - valid",
"data": {
"foo": 1,
"baz": 3
},
"valid": true
},
{
"description": "both valid - invalid",
"data": {
"foo": 1,
"bar": 2,
"baz": 3
},
"valid": false
}
]
},
{
"description": "oneOf with missing optional property",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"properties": {
"bar": true,
"baz": true
},
"required": [
"bar"
]
},
{
"properties": {
"foo": true
},
"required": [
"foo"
]
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {
"bar": 8
},
"valid": true
},
{
"description": "second oneOf valid",
"data": {
"foo": "foo"
},
"valid": true
},
{
"description": "both oneOf valid",
"data": {
"foo": "foo",
"bar": 8
},
"valid": false
},
{
"description": "neither oneOf valid",
"data": {
"baz": "quux"
},
"valid": false
}
]
},
{
"description": "nested oneOf, to check validation semantics",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"oneOf": [
{
"type": "null"
}
]
}
]
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "anything non-null is invalid",
"data": 123,
"valid": false
}
]
}
]

View File

@ -1,128 +0,0 @@
[
{
"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
}
]
}
]

View File

@ -1,35 +0,0 @@
[
{
"description": "pattern validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"pattern": "^a*$"
},
"tests": [
{
"description": "a matching pattern is valid",
"data": "aaa",
"valid": true
},
{
"description": "a non-matching pattern is invalid",
"data": "abc",
"valid": false
}
]
},
{
"description": "pattern is not anchored",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"pattern": "a+"
},
"tests": [
{
"description": "matches a substring",
"data": "xxaayy",
"valid": true
}
]
}
]

View File

@ -1,216 +0,0 @@
[
{
"description": "patternProperties validates properties matching a regex",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": {
"f.*o": {
"type": "integer"
}
}
},
"tests": [
{
"description": "a single valid match is valid",
"data": {
"foo": 1
},
"valid": true
},
{
"description": "multiple valid matches is valid",
"data": {
"foo": 1,
"foooooo": 2
},
"valid": true
},
{
"description": "a single invalid match is invalid",
"data": {
"foo": "bar",
"fooooo": 2
},
"valid": false
},
{
"description": "multiple invalid matches is invalid",
"data": {
"foo": "bar",
"foooooo": "baz"
},
"valid": false
}
]
},
{
"description": "multiple simultaneous patternProperties are validated",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": {
"a*": {
"type": "integer"
},
"aaa*": {
"maximum": 20
}
}
},
"tests": [
{
"description": "a single valid match is valid",
"data": {
"a": 21
},
"valid": true
},
{
"description": "a simultaneous match is valid",
"data": {
"aaaa": 18
},
"valid": true
},
{
"description": "multiple matches is valid",
"data": {
"a": 21,
"aaaa": 18
},
"valid": true
},
{
"description": "an invalid due to one is invalid",
"data": {
"a": "bar"
},
"valid": false
},
{
"description": "an invalid due to the other is invalid",
"data": {
"aaaa": 31
},
"valid": false
},
{
"description": "an invalid due to both is invalid",
"data": {
"aaa": "foo",
"aaaa": 31
},
"valid": false
}
]
},
{
"description": "regexes are not anchored by default and are case sensitive",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": {
"[0-9]{2,}": {
"type": "boolean"
},
"X_": {
"type": "string"
}
}
},
"tests": [
{
"description": "non recognized members are ignored",
"data": {
"answer 1": "42"
},
"valid": true
},
{
"description": "recognized members are accounted for",
"data": {
"a31b": null
},
"valid": false
},
{
"description": "regexes are case sensitive",
"data": {
"a_x_3": 3
},
"valid": true
},
{
"description": "regexes are case sensitive, 2",
"data": {
"a_X_3": 3
},
"valid": false
}
]
},
{
"description": "patternProperties with boolean schemas",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": {
"f.*": true,
"b.*": false
}
},
"tests": [
{
"description": "object with property matching schema true is valid",
"data": {
"foo": 1
},
"valid": true
},
{
"description": "object with property matching schema false is invalid",
"data": {
"bar": 2
},
"valid": false
},
{
"description": "object with both properties is invalid",
"data": {
"foo": 1,
"bar": 2
},
"valid": false
},
{
"description": "object with a property matching both true and false is invalid",
"data": {
"foobar": 1
},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "patternProperties with null valued instance properties",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": {
"^.*bar$": {
"type": "null"
}
}
},
"tests": [
{
"description": "allows null values",
"data": {
"foobar": null
},
"valid": true
}
]
}
]

View File

@ -1,22 +0,0 @@
[
{
"description": "prefixItems with null instance elements",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [
{
"type": "null"
}
]
},
"tests": [
{
"description": "allows null elements",
"data": [
null
],
"valid": true
}
]
}
]

View File

@ -1,245 +0,0 @@
[
{
"description": "properties with escaped characters",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"foo\nbar": {
"type": "number"
},
"foo\"bar": {
"type": "number"
},
"foo\\bar": {
"type": "number"
},
"foo\rbar": {
"type": "number"
},
"foo\tbar": {
"type": "number"
},
"foo\fbar": {
"type": "number"
}
}
},
"tests": [
{
"description": "object with all numbers is valid",
"data": {
"foo\nbar": 1,
"foo\"bar": 1,
"foo\\bar": 1,
"foo\rbar": 1,
"foo\tbar": 1,
"foo\fbar": 1
},
"valid": true
},
{
"description": "object with strings is invalid",
"data": {
"foo\nbar": "1",
"foo\"bar": "1",
"foo\\bar": "1",
"foo\rbar": "1",
"foo\tbar": "1",
"foo\fbar": "1"
},
"valid": false
}
]
},
{
"description": "properties with null valued instance properties",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"foo": {
"type": "null"
}
}
},
"tests": [
{
"description": "allows null values",
"data": {
"foo": null
},
"valid": true
}
]
},
{
"description": "properties whose names are Javascript object property names",
"comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"__proto__": {
"type": "number"
},
"toString": {
"properties": {
"length": {
"type": "string"
}
}
},
"constructor": {
"type": "number"
}
}
},
"tests": [
{
"description": "none of the properties mentioned",
"data": {},
"valid": true
},
{
"description": "__proto__ not valid",
"data": {
"__proto__": "foo"
},
"valid": false
},
{
"description": "toString not valid",
"data": {
"toString": {
"length": 37
}
},
"valid": false
},
{
"description": "constructor not valid",
"data": {
"constructor": {
"length": 37
}
},
"valid": false
},
{
"description": "all present and valid",
"data": {
"__proto__": 12,
"toString": {
"length": "foo"
},
"constructor": 37
},
"valid": true
}
]
},
{
"description": "property merging across multi-level inheritance",
"enums": [],
"puncs": [],
"types": [
{
"name": "properties_test.entity",
"schemas": [
{
"$id": "properties_test.entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string",
"const": "properties_test.entity"
}
},
"required": [
"id"
]
}
]
},
{
"name": "properties_test.user",
"schemas": [
{
"$id": "properties_test.user",
"$ref": "properties_test.entity",
"properties": {
"type": {
"type": "string",
"const": "properties_test.user",
"override": true
},
"password": {
"type": "string",
"minLength": 8
}
},
"required": [
"password"
]
}
]
},
{
"name": "properties_test.person",
"schemas": [
{
"$id": "properties_test.person",
"$ref": "properties_test.user",
"properties": {
"type": {
"type": "string",
"const": "properties_test.person",
"override": true
},
"first_name": {
"type": "string",
"minLength": 1
},
"last_name": {
"type": "string",
"minLength": 1
}
},
"required": [
"first_name",
"last_name"
]
}
]
}
],
"tests": [
{
"description": "person inherits all properties correctly",
"schema_id": "properties_test.person",
"data": {},
"valid": true
},
{
"description": "validation keywords inherited and applied",
"schema_id": "properties_test.person",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "MIN_LENGTH_VIOLATED",
"path": "/password"
},
{
"code": "MIN_LENGTH_VIOLATED",
"path": "/first_name"
}
]
}
]
}
]

View File

@ -1,152 +0,0 @@
[
{
"description": "propertyNames validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {
"maxLength": 3
}
},
"tests": [
{
"description": "all property names valid",
"data": {},
"valid": true
},
{
"description": "some property names invalid",
"data": {},
"valid": false
},
{
"description": "object without properties is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames validation with pattern",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {
"pattern": "^a+$"
}
},
"tests": [
{
"description": "matching property names valid",
"data": {},
"valid": true
},
{
"description": "non-matching property name is invalid",
"data": {},
"valid": false
},
{
"description": "object without properties is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with boolean schema true",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": true
},
"tests": [
{
"description": "object with any properties is valid",
"data": {},
"valid": true
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with boolean schema false",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": false
},
"tests": [
{
"description": "object with any properties is invalid",
"data": {},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with const",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {
"const": "foo"
}
},
"tests": [
{
"description": "object with property foo is valid",
"data": {},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with enum",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {
"enum": [
"foo",
"bar"
]
}
},
"tests": [
{
"description": "object with property foo is valid",
"data": {},
"valid": true
},
{
"description": "object with property foo and bar is valid",
"data": {},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
}
]

View File

@ -1,200 +0,0 @@
[
{
"description": "punc-specific resolution and local refs",
"enums": [],
"types": [
{
"name": "global_thing",
"schemas": [
{
"$id": "global_thing",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"type": "string"
}
},
"required": [
"id",
"type"
]
}
]
},
{
"name": "punc_entity",
"schemas": [
{
"$id": "punc_entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"id",
"type"
]
}
]
},
{
"name": "punc_person",
"schemas": [
{
"$id": "punc_person",
"$ref": "punc_entity",
"properties": {
"first_name": {
"type": "string",
"minLength": 1
},
"last_name": {
"type": "string",
"minLength": 1
},
"address": {
"type": "object",
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string"
}
},
"required": [
"street",
"city"
]
}
}
}
]
}
],
"puncs": [
{
"name": "public_ref_test",
"public": true,
"schemas": [
{
"$id": "public_ref_test.request",
"$ref": "punc_person"
}
]
},
{
"name": "private_ref_test",
"public": false,
"schemas": [
{
"$id": "private_ref_test.request",
"$ref": "punc_person"
}
]
},
{
"name": "punc_with_local_ref_test",
"public": false,
"schemas": [
{
"$id": "local_address",
"type": "object",
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string"
}
},
"required": [
"street",
"city"
]
},
{
"$id": "punc_with_local_ref_test.request",
"$ref": "local_address"
}
]
},
{
"name": "punc_with_local_ref_to_global_test",
"public": false,
"schemas": [
{
"$id": "local_user_with_thing",
"type": "object",
"properties": {
"user_name": {
"type": "string"
},
"thing": {
"$ref": "global_thing"
}
},
"required": [
"user_name",
"thing"
]
},
{
"$id": "punc_with_local_ref_to_global_test.request",
"$ref": "local_user_with_thing"
}
]
}
],
"tests": [
{
"description": "valid instance with address passes in public punc",
"schema_id": "public_ref_test.request",
"data": {},
"valid": true
},
{
"description": "punc local ref resolution",
"schema_id": "punc_with_local_ref_test.request",
"data": {},
"valid": true
},
{
"description": "punc local ref missing requirement",
"schema_id": "punc_with_local_ref_test.request",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/city"
}
]
},
{
"description": "punc local ref to global type - invalid format",
"schema_id": "punc_with_local_ref_to_global_test.request",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "FORMAT_INVALID",
"path": "/thing/id"
}
]
}
]
}
]

View File

@ -1,208 +0,0 @@
[
{
"description": "root pointer ref",
"schema": {
"properties": {
"foo": {
"$ref": "#"
}
}
},
"tests": [
{
"description": "match self",
"data": {
"foo": false
},
"valid": true
},
{
"description": "recursive match",
"data": {
"foo": {
"foo": false
}
},
"valid": true
},
{
"description": "mismatch",
"data": {
"bar": false
},
"valid": false
},
{
"description": "recursive mismatch",
"data": {
"foo": {
"bar": false
}
},
"valid": false
}
]
},
{
"description": "relative pointer ref to object",
"schema": {
"$id": "http://example.com/root.json",
"definitions": {
"foo": {
"type": "integer"
},
"bar": {
"$ref": "#/definitions/foo"
}
},
"$ref": "#/definitions/bar"
},
"tests": [
{
"description": "match integer",
"data": 1,
"valid": true
},
{
"description": "mismatch string",
"data": "a",
"valid": false
}
]
},
{
"description": "escaped pointer ref",
"schema": {
"$id": "http://example.com/tilda.json",
"definitions": {
"tilde~field": {
"type": "integer"
},
"slash/field": {
"type": "integer"
},
"percent%field": {
"type": "integer"
}
},
"properties": {
"tilde": {
"$ref": "#/definitions/tilde~0field"
},
"slash": {
"$ref": "#/definitions/slash~1field"
},
"percent": {
"$ref": "#/definitions/percent%25field"
}
}
},
"tests": [
{
"description": "slash valid",
"data": {
"slash": 1
},
"valid": true
},
{
"description": "tilde valid",
"data": {
"tilde": 1
},
"valid": true
},
{
"description": "percent valid",
"data": {
"percent": 1
},
"valid": true
},
{
"description": "slash invalid",
"data": {
"slash": "a"
},
"valid": false
}
]
},
{
"description": "nested refs",
"schema": {
"$id": "http://example.com/nested.json",
"definitions": {
"a": {
"type": "integer"
},
"b": {
"$ref": "#/definitions/a"
},
"c": {
"$ref": "#/definitions/b"
}
},
"$ref": "#/definitions/c"
},
"tests": [
{
"description": "nested match",
"data": 5,
"valid": true
},
{
"description": "nested mismatch",
"data": "a",
"valid": false
}
]
},
{
"description": "ref to array item",
"schema": {
"prefixItems": [
{
"type": "integer"
},
{
"type": "string"
}
],
"definitions": {
"first": {
"$ref": "#/prefixItems/0"
},
"second": {
"$ref": "#/prefixItems/1"
}
},
"properties": {
"a": {
"$ref": "#/definitions/first"
},
"b": {
"$ref": "#/definitions/second"
}
}
},
"tests": [
{
"description": "valid array items",
"data": {
"a": 1,
"b": "foo"
},
"valid": true
},
{
"description": "invalid array items",
"data": {
"a": "foo",
"b": 1
},
"valid": false
}
]
}
]

View File

@ -1,279 +0,0 @@
[
{
"description": "required with empty array",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"foo": {}
},
"required": []
},
"tests": [
{
"description": "property not required",
"data": {},
"valid": true
}
]
},
{
"description": "required with escaped characters",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"foo\nbar",
"foo\"bar",
"foo\\bar",
"foo\rbar",
"foo\tbar",
"foo\fbar"
]
},
"tests": [
{
"description": "object with all properties present is valid",
"data": {},
"valid": true
},
{
"description": "object with some properties missing is invalid",
"data": {},
"valid": false
}
]
},
{
"description": "required properties whose names are Javascript object property names",
"comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"__proto__",
"toString",
"constructor"
]
},
"tests": [
{
"description": "none of the properties mentioned",
"data": {},
"valid": false
},
{
"description": "__proto__ present",
"data": {},
"valid": false
},
{
"description": "toString present",
"data": {},
"valid": false
},
{
"description": "constructor present",
"data": {},
"valid": false
},
{
"description": "all present",
"data": {},
"valid": true
}
]
},
{
"description": "basic required property validation",
"enums": [],
"types": [],
"puncs": [
{
"name": "basic_validation_test",
"public": false,
"schemas": [
{
"$id": "basic_validation_test.request",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer",
"minimum": 0
}
},
"required": [
"name",
"age"
]
}
]
}
],
"tests": [
{
"description": "missing all required fields",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/name"
},
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/age"
}
]
},
{
"description": "missing some required fields",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/age"
}
]
}
]
},
{
"description": "required property merging across inheritance",
"enums": [],
"puncs": [],
"types": [
{
"name": "entity",
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"type": {
"type": "string"
},
"created_by": {
"type": "string",
"format": "uuid"
}
},
"required": [
"id",
"type",
"created_by"
]
}
]
},
{
"name": "user",
"schemas": [
{
"$id": "user",
"base": "entity",
"$ref": "entity",
"properties": {
"password": {
"type": "string",
"minLength": 8
}
},
"if": {
"properties": {
"type": {
"const": "user"
}
}
},
"then": {
"required": [
"password"
]
}
}
]
},
{
"name": "person",
"schemas": [
{
"$id": "person",
"base": "user",
"$ref": "user",
"properties": {
"first_name": {
"type": "string",
"minLength": 1
},
"last_name": {
"type": "string",
"minLength": 1
}
},
"if": {
"properties": {
"type": {
"const": "person"
}
}
},
"then": {
"required": [
"first_name",
"last_name"
]
}
}
]
}
],
"tests": [
{
"description": "missing all required fields across inheritance chain",
"schema_id": "person",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/id"
},
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/created_by"
},
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/first_name"
},
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/last_name"
}
]
},
{
"description": "conditional requirements through inheritance",
"schema_id": "person",
"data": {},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/first_name"
},
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/last_name"
}
]
}
]
}
]

View File

@ -1,204 +0,0 @@
[
{
"description": "basic validation integrity",
"enums": [],
"types": [],
"puncs": [
{
"name": "simple",
"public": false,
"schemas": [
{
"$id": "simple.request",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer",
"minimum": 0
}
},
"required": [
"name",
"age"
]
}
]
},
{
"name": "object_test",
"public": false,
"schemas": [
{
"$id": "object_test.request",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer",
"minimum": 0
}
},
"required": [
"name",
"age"
]
}
]
},
{
"name": "array_test",
"public": false,
"schemas": [
{
"$id": "array_test.request",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
}
}
}
}
]
}
],
"tests": [
{
"description": "valid instance",
"schema_id": "simple.request",
"data": {
"name": "Alice",
"age": 30
},
"valid": true
},
{
"description": "invalid type - negative age",
"schema_id": "simple.request",
"data": {
"name": "Bob",
"age": -5
},
"valid": false,
"expect_errors": [
{
"code": "MINIMUM_VIOLATED",
"path": "/age",
"context": -5,
"cause": {
"got": -5.0,
"want": 0.0
}
}
]
},
{
"description": "missing required field",
"schema_id": "simple.request",
"data": {
"name": "Charlie"
},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/age",
"cause": {
"want": [
"age"
]
}
}
]
},
{
"description": "valid object root type",
"schema_id": "object_test.request",
"data": {
"name": "test",
"age": 25
},
"valid": true
},
{
"description": "valid array root type",
"schema_id": "array_test.request",
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000"
}
],
"valid": true
},
{
"description": "valid empty array",
"schema_id": "array_test.request",
"data": [],
"valid": true
},
{
"description": "null against array schema",
"schema_id": "array_test.request",
"data": null,
"valid": false,
"expect_errors": [
{
"code": "TYPE_MISMATCH",
"path": "",
"context": null,
"cause": {
"got": "null",
"want": "array"
}
}
]
},
{
"description": "object against array schema",
"schema_id": "array_test.request",
"data": {
"id": "not-an-array"
},
"valid": false,
"expect_errors": [
{
"code": "TYPE_MISMATCH",
"path": "",
"context": {
"id": "not-an-array"
},
"cause": {
"got": "object",
"want": "array"
}
}
]
},
{
"description": "string against object schema",
"schema_id": "object_test.request",
"data": "not an object",
"valid": false,
"expect_errors": [
{
"code": "TYPE_MISMATCH",
"path": "",
"context": "not an object",
"cause": {
"got": "string",
"want": "object"
}
}
]
}
]
}
]

View File

@ -1 +0,0 @@
[]

View File

@ -1,66 +0,0 @@
[
{
"description": "title metadata override logic",
"enums": [],
"types": [
{
"name": "base_with_title",
"schemas": [
{
"$id": "base_with_title",
"type": "object",
"title": "Base Title",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"name"
]
}
]
},
{
"name": "override_with_title",
"schemas": [
{
"$id": "override_with_title",
"base": "base_with_title",
"$ref": "base_with_title",
"title": "Override Title"
}
]
}
],
"puncs": [],
"tests": [
{
"description": "valid instance with title override schema",
"schema_id": "override_with_title",
"data": {
"name": "test",
"type": "base_with_title"
},
"valid": true
},
{
"description": "invalid instance - missing name required by base schema",
"schema_id": "override_with_title",
"data": {
"type": "override_with_title"
},
"valid": false,
"expect_errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"path": "/name"
}
]
}
]
}
]

View File

@ -1,319 +0,0 @@
[
{
"description": "array type matches arrays",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array"
},
"tests": [
{
"description": "an integer is not an array",
"data": 1,
"valid": false
},
{
"description": "a float is not an array",
"data": 1.1,
"valid": false
},
{
"description": "a string is not an array",
"data": "foo",
"valid": false
},
{
"description": "an object is not an array",
"data": {},
"valid": false
},
{
"description": "an array is an array",
"data": [],
"valid": true
},
{
"description": "a boolean is not an array",
"data": true,
"valid": false
},
{
"description": "null is not an array",
"data": null,
"valid": false
}
]
},
{
"description": "boolean type matches booleans",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "boolean"
},
"tests": [
{
"description": "an integer is not a boolean",
"data": 1,
"valid": false
},
{
"description": "zero is not a boolean",
"data": 0,
"valid": false
},
{
"description": "a float is not a boolean",
"data": 1.1,
"valid": false
},
{
"description": "a string is not a boolean",
"data": "foo",
"valid": false
},
{
"description": "an empty string is not a boolean",
"data": "",
"valid": false
},
{
"description": "an object is not a boolean",
"data": {},
"valid": false
},
{
"description": "an array is not a boolean",
"data": [],
"valid": false
},
{
"description": "true is a boolean",
"data": true,
"valid": true
},
{
"description": "false is a boolean",
"data": false,
"valid": true
},
{
"description": "null is not a boolean",
"data": null,
"valid": false
}
]
},
{
"description": "null type matches only the null object",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "null"
},
"tests": [
{
"description": "an integer is not null",
"data": 1,
"valid": false
},
{
"description": "a float is not null",
"data": 1.1,
"valid": false
},
{
"description": "zero is not null",
"data": 0,
"valid": false
},
{
"description": "a string is not null",
"data": "foo",
"valid": false
},
{
"description": "an empty string is not null",
"data": "",
"valid": false
},
{
"description": "an object is not null",
"data": {},
"valid": false
},
{
"description": "an array is not null",
"data": [],
"valid": false
},
{
"description": "true is not null",
"data": true,
"valid": false
},
{
"description": "false is not null",
"data": false,
"valid": false
},
{
"description": "null is null",
"data": null,
"valid": true
}
]
},
{
"description": "multiple types can be specified in an array",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [
"integer",
"string"
]
},
"tests": [
{
"description": "an integer is valid",
"data": 1,
"valid": true
},
{
"description": "a string is valid",
"data": "foo",
"valid": true
},
{
"description": "a float is invalid",
"data": 1.1,
"valid": false
},
{
"description": "an object is invalid",
"data": {},
"valid": false
},
{
"description": "an array is invalid",
"data": [],
"valid": false
},
{
"description": "a boolean is invalid",
"data": true,
"valid": false
},
{
"description": "null is invalid",
"data": null,
"valid": false
}
]
},
{
"description": "type as array with one item",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [
"string"
]
},
"tests": [
{
"description": "string is valid",
"data": "foo",
"valid": true
},
{
"description": "number is invalid",
"data": 123,
"valid": false
}
]
},
{
"description": "type: array or object",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [
"array",
"object"
]
},
"tests": [
{
"description": "array is valid",
"data": [
1,
2,
3
],
"valid": true
},
{
"description": "object is valid",
"data": {
"foo": 123
},
"valid": true
},
{
"description": "number is invalid",
"data": 123,
"valid": false
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
},
{
"description": "null is invalid",
"data": null,
"valid": false
}
]
},
{
"description": "type: array, object or null",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [
"array",
"object",
"null"
]
},
"tests": [
{
"description": "array is valid",
"data": [
1,
2,
3
],
"valid": true
},
{
"description": "object is valid",
"data": {
"foo": 123
},
"valid": true
},
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "number is invalid",
"data": 123,
"valid": false
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
}
]
}
]

View File

@ -1,855 +0,0 @@
[
{
"description": "inheritance type matching and overrides",
"types": [
{
"name": "entity",
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
]
},
{
"name": "job",
"schemas": [
{
"$id": "job",
"$ref": "entity",
"properties": {
"type": {
"type": "string",
"const": "job",
"override": true
},
"job_id": {
"type": "string"
}
}
}
]
},
{
"name": "super_job",
"schemas": [
{
"$id": "super_job",
"$ref": "job",
"properties": {
"type": {
"type": "string",
"const": "super_job",
"override": true
},
"manager_id": {
"type": "string"
}
}
},
{
"$id": "super_job.short",
"$ref": "super_job",
"properties": {
"name": {
"type": "string",
"maxLength": 10
}
}
}
]
}
],
"tests": [
{
"description": "valid job instance",
"schema_id": "job",
"data": {
"id": "1",
"type": "job",
"name": "my job",
"job_id": "job123"
},
"valid": true
},
{
"description": "invalid job instance - wrong type const",
"schema_id": "job",
"data": {
"id": "1",
"type": "not_job",
"name": "my job",
"job_id": "job123"
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/type"
}
]
},
{
"description": "valid super_job instance",
"schema_id": "super_job",
"data": {
"id": "1",
"type": "super_job",
"name": "my super job",
"job_id": "job123",
"manager_id": "mgr1"
},
"valid": true
},
{
"description": "valid super_job.short instance",
"schema_id": "super_job.short",
"data": {
"id": "1",
"type": "super_job",
"name": "short",
"job_id": "job123",
"manager_id": "mgr1"
},
"valid": true
},
{
"description": "invalid super_job.short - type must be super_job not job",
"schema_id": "super_job.short",
"data": {
"id": "1",
"type": "job",
"name": "short",
"job_id": "job123",
"manager_id": "mgr1"
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/type"
}
]
}
]
},
{
"description": "union type matching with const discriminators",
"types": [
{
"name": "union_base",
"schemas": [
{
"$id": "union_base",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"id",
"type"
]
}
]
},
{
"name": "union_a",
"schemas": [
{
"$id": "union_a",
"$ref": "union_base",
"properties": {
"type": {
"const": "union_a",
"override": true
},
"prop_a": {
"type": "string"
}
},
"required": [
"prop_a"
]
}
]
},
{
"name": "union_b",
"schemas": [
{
"$id": "union_b",
"$ref": "union_base",
"properties": {
"type": {
"const": "union_b",
"override": true
},
"prop_b": {
"type": "number"
}
},
"required": [
"prop_b"
]
}
]
},
{
"name": "union_c",
"schemas": [
{
"$id": "union_c",
"base": "union_base",
"$ref": "union_base",
"properties": {
"type": {
"const": "union_c",
"override": true
},
"prop_c": {
"type": "boolean"
}
},
"required": [
"prop_c"
]
}
]
}
],
"puncs": [
{
"name": "union_test",
"public": true,
"schemas": [
{
"$id": "union_test.request",
"type": "object",
"properties": {
"union_prop": {
"oneOf": [
{
"$ref": "union_a"
},
{
"$ref": "union_b"
},
{
"$ref": "union_c"
}
]
}
}
}
]
}
],
"tests": [
{
"description": "valid union variant A",
"schema_id": "union_test.request",
"data": {
"union_prop": {
"id": "123",
"type": "union_a",
"prop_a": "hello"
}
},
"valid": true
},
{
"description": "valid union variant B",
"schema_id": "union_test.request",
"data": {
"union_prop": {
"id": "456",
"type": "union_b",
"prop_b": 123
}
},
"valid": true
},
{
"description": "invalid variant - wrong discriminator",
"schema_id": "union_test.request",
"data": {
"union_prop": {
"id": "789",
"type": "union_b",
"prop_a": "hello"
}
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/union_prop/type"
}
]
},
{
"description": "valid union variant C",
"schema_id": "union_test.request",
"data": {
"union_prop": {
"id": "789",
"type": "union_c",
"prop_c": true
}
},
"valid": true
},
{
"description": "invalid instance - base type should fail due to override",
"schema_id": "union_test.request",
"data": {
"union_prop": {
"id": "101",
"type": "union_base",
"prop_a": "world"
}
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/union_prop/type"
}
]
}
]
},
{
"description": "nullable union validation",
"types": [
{
"name": "thing_base",
"schemas": [
{
"$id": "thing_base",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "thing_base"
},
"id": {
"type": "string"
}
},
"required": [
"type",
"id"
]
}
]
},
{
"name": "thing_a",
"schemas": [
{
"$id": "thing_a",
"base": "thing_base",
"$ref": "thing_base",
"properties": {
"type": {
"type": "string",
"const": "thing_a",
"override": true
},
"prop_a": {
"type": "string"
}
},
"required": [
"prop_a"
]
}
]
},
{
"name": "thing_b",
"schemas": [
{
"$id": "thing_b",
"base": "thing_base",
"$ref": "thing_base",
"properties": {
"type": {
"type": "string",
"const": "thing_b",
"override": true
},
"prop_b": {
"type": "string"
}
},
"required": [
"prop_b"
]
}
]
}
],
"puncs": [
{
"name": "nullable_union_test",
"public": true,
"schemas": [
{
"$id": "nullable_union_test.request",
"type": "object",
"properties": {
"nullable_prop": {
"oneOf": [
{
"$ref": "thing_a"
},
{
"$ref": "thing_b"
},
{
"type": "null"
}
]
}
}
}
]
}
],
"tests": [
{
"description": "valid thing_a",
"schema_id": "nullable_union_test.request",
"data": {
"nullable_prop": {
"id": "123",
"type": "thing_a",
"prop_a": "hello"
}
},
"valid": true
},
{
"description": "valid thing_b",
"schema_id": "nullable_union_test.request",
"data": {
"nullable_prop": {
"id": "456",
"type": "thing_b",
"prop_b": "goodbye"
}
},
"valid": true
},
{
"description": "valid null",
"schema_id": "nullable_union_test.request",
"data": {
"nullable_prop": null
},
"valid": true
},
{
"description": "invalid base type",
"schema_id": "nullable_union_test.request",
"data": {
"nullable_prop": {
"id": "789",
"type": "thing_base",
"prop_a": "should fail"
}
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/nullable_prop/type"
}
]
},
{
"description": "invalid type (string)",
"schema_id": "nullable_union_test.request",
"data": {
"nullable_prop": "not_an_object_or_null"
},
"valid": false,
"expect_errors": [
{
"code": "TYPE_MISMATCH",
"path": "/nullable_prop"
}
]
}
]
},
{
"description": "type hierarchy descendants matching (family schemas)",
"types": [
{
"name": "entity",
"hierarchy": [
"entity"
],
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
]
},
{
"name": "organization",
"hierarchy": [
"entity",
"organization"
],
"schemas": [
{
"$id": "organization",
"$ref": "entity",
"properties": {
"type": {
"$ref": "organization.family",
"override": true
},
"name": {
"type": "string"
}
}
}
]
},
{
"name": "person",
"hierarchy": [
"entity",
"organization",
"person"
],
"schemas": [
{
"$id": "person",
"$ref": "organization",
"properties": {
"type": {
"const": "person",
"override": true
},
"first_name": {
"type": "string"
}
}
}
]
}
],
"tests": [
{
"description": "derived type (person) matches base schema (organization) via family ref",
"schema_id": "organization",
"data": {
"id": "p1",
"type": "person",
"name": "John",
"first_name": "John"
},
"valid": true
},
{
"description": "base type matches its own schema",
"schema_id": "organization",
"data": {
"id": "o1",
"type": "organization",
"name": "ACME"
},
"valid": true
},
{
"description": "ancestor type (entity) fails derived schema (organization)",
"schema_id": "organization",
"data": {
"id": "e1",
"type": "entity"
},
"valid": false,
"expect_errors": [
{
"code": "ENUM_VIOLATED",
"path": "/type"
}
]
},
{
"description": "unrelated type (job) fails derived schema (organization)",
"schema_id": "organization",
"data": {
"id": "job-1",
"type": "job",
"name": "Should Fail"
},
"valid": false,
"expect_errors": [
{
"code": "ENUM_VIOLATED",
"path": "/type"
}
]
}
]
},
{
"description": "complex punc type matching with oneOf and nested refs",
"types": [
{
"name": "entity",
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
]
},
{
"name": "job",
"schemas": [
{
"$id": "job",
"$ref": "entity",
"properties": {
"type": {
"type": "string",
"const": "job",
"override": true
},
"job_id": {
"type": "string"
}
}
}
]
},
{
"name": "super_job",
"schemas": [
{
"$id": "super_job",
"$ref": "job",
"extensible": false,
"properties": {
"type": {
"type": "string",
"const": "super_job",
"override": true
},
"manager_id": {
"type": "string"
}
}
},
{
"$id": "super_job.short",
"$ref": "super_job",
"properties": {
"name": {
"type": "string",
"maxLength": 10
}
}
}
]
}
],
"puncs": [
{
"name": "type_test_punc",
"public": true,
"schemas": [
{
"$id": "type_test_punc.request",
"type": "object",
"properties": {
"root_job": {
"$ref": "job"
},
"nested_or_super_job": {
"oneOf": [
{
"$ref": "super_job"
},
{
"type": "object",
"properties": {
"my_job": {
"$ref": "job"
}
},
"required": [
"my_job"
]
}
]
}
},
"required": [
"root_job",
"nested_or_super_job"
]
}
]
},
{
"name": "test_org_punc",
"public": false,
"schemas": [
{
"$id": "test_org_punc.request",
"$ref": "organization"
}
]
}
],
"tests": [
{
"description": "valid punc instance with mixed job types",
"schema_id": "type_test_punc.request",
"data": {
"root_job": {
"type": "job",
"name": "root job",
"job_id": "job456"
},
"nested_or_super_job": {
"type": "super_job",
"name": "nested super job",
"job_id": "job789",
"manager_id": "mgr2"
}
},
"valid": true
},
{
"description": "invalid type at punc root ref (job expected, entity given)",
"schema_id": "type_test_punc.request",
"data": {
"root_job": {
"type": "entity",
"name": "root job",
"job_id": "job456"
},
"nested_or_super_job": {
"type": "super_job",
"name": "nested super job",
"job_id": "job789",
"manager_id": "mgr2"
}
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/root_job/type"
}
]
},
{
"description": "invalid type at punc nested ref (job expected, entity given)",
"schema_id": "type_test_punc.request",
"data": {
"root_job": {
"type": "job",
"name": "root job",
"job_id": "job456"
},
"nested_or_super_job": {
"my_job": {
"type": "entity",
"name": "nested job",
"job_id": "job789"
}
}
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/nested_or_super_job/my_job/type"
}
]
},
{
"description": "invalid type at punc oneOf ref (super_job expected, job given)",
"schema_id": "type_test_punc.request",
"data": {
"root_job": {
"type": "job",
"name": "root job",
"job_id": "job456"
},
"nested_or_super_job": {
"type": "job",
"name": "nested super job",
"job_id": "job789",
"manager_id": "mgr2"
}
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/nested_or_super_job/type"
}
]
},
{
"description": "valid person against organization punc",
"schema_id": "test_org_punc.request",
"data": {
"id": "person-1",
"type": "person",
"name": "John Doe",
"first_name": "John"
},
"valid": true
}
]
}
]

View File

@ -1,694 +0,0 @@
[
{
"description": "uniqueItems validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"uniqueItems": true
},
"tests": [
{
"description": "unique array of integers is valid",
"data": [
1,
2
],
"valid": true
},
{
"description": "non-unique array of integers is invalid",
"data": [
1,
1
],
"valid": false
},
{
"description": "non-unique array of more than two integers is invalid",
"data": [
1,
2,
1
],
"valid": false
},
{
"description": "numbers are unique if mathematically unequal",
"data": [
1.0,
1.0,
1
],
"valid": false
},
{
"description": "false is not equal to zero",
"data": [
0,
false
],
"valid": true
},
{
"description": "true is not equal to one",
"data": [
1,
true
],
"valid": true
},
{
"description": "unique array of strings is valid",
"data": [
"foo",
"bar",
"baz"
],
"valid": true
},
{
"description": "non-unique array of strings is invalid",
"data": [
"foo",
"bar",
"foo"
],
"valid": false
},
{
"description": "unique array of objects is valid",
"data": [
{
"foo": "bar"
},
{
"foo": "baz"
}
],
"valid": true
},
{
"description": "non-unique array of objects is invalid",
"data": [
{
"foo": "bar"
},
{
"foo": "bar"
}
],
"valid": false
},
{
"description": "property order of array of objects is ignored",
"data": [
{
"foo": "bar",
"bar": "foo"
},
{
"bar": "foo",
"foo": "bar"
}
],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
{
"foo": {
"bar": {
"baz": true
}
}
},
{
"foo": {
"bar": {
"baz": false
}
}
}
],
"valid": true
},
{
"description": "non-unique array of nested objects is invalid",
"data": [
{
"foo": {
"bar": {
"baz": true
}
}
},
{
"foo": {
"bar": {
"baz": true
}
}
}
],
"valid": false
},
{
"description": "unique array of arrays is valid",
"data": [
[
"foo"
],
[
"bar"
]
],
"valid": true
},
{
"description": "non-unique array of arrays is invalid",
"data": [
[
"foo"
],
[
"foo"
]
],
"valid": false
},
{
"description": "non-unique array of more than two arrays is invalid",
"data": [
[
"foo"
],
[
"bar"
],
[
"foo"
]
],
"valid": false
},
{
"description": "1 and true are unique",
"data": [
1,
true
],
"valid": true
},
{
"description": "0 and false are unique",
"data": [
0,
false
],
"valid": true
},
{
"description": "[1] and [true] are unique",
"data": [
[
1
],
[
true
]
],
"valid": true
},
{
"description": "[0] and [false] are unique",
"data": [
[
0
],
[
false
]
],
"valid": true
},
{
"description": "nested [1] and [true] are unique",
"data": [
[
[
1
],
"foo"
],
[
[
true
],
"foo"
]
],
"valid": true
},
{
"description": "nested [0] and [false] are unique",
"data": [
[
[
0
],
"foo"
],
[
[
false
],
"foo"
]
],
"valid": true
},
{
"description": "unique heterogeneous types are valid",
"data": [
{},
[
1
],
true,
null,
1,
"{}"
],
"valid": true
},
{
"description": "non-unique heterogeneous types are invalid",
"data": [
{},
[
1
],
true,
null,
{},
1
],
"valid": false
},
{
"description": "different objects are unique",
"data": [
{
"a": 1,
"b": 2
},
{
"a": 2,
"b": 1
}
],
"valid": true
},
{
"description": "objects are non-unique despite key order",
"data": [
{
"a": 1,
"b": 2
},
{
"b": 2,
"a": 1
}
],
"valid": false
},
{
"description": "{\"a\": false} and {\"a\": 0} are unique",
"data": [
{
"a": false
},
{
"a": 0
}
],
"valid": true
},
{
"description": "{\"a\": true} and {\"a\": 1} are unique",
"data": [
{
"a": true
},
{
"a": 1
}
],
"valid": true
}
]
},
{
"description": "uniqueItems with an array of items",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [
{
"type": "boolean"
},
{
"type": "boolean"
}
],
"uniqueItems": true
},
"tests": [
{
"description": "[false, true] from items array is valid",
"data": [
false,
true
],
"valid": true
},
{
"description": "[true, false] from items array is valid",
"data": [
true,
false
],
"valid": true
},
{
"description": "[false, false] from items array is not valid",
"data": [
false,
false
],
"valid": false
},
{
"description": "[true, true] from items array is not valid",
"data": [
true,
true
],
"valid": false
}
]
},
{
"description": "uniqueItems=false validation",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"uniqueItems": false
},
"tests": [
{
"description": "unique array of integers is valid",
"data": [
1,
2
],
"valid": true
},
{
"description": "non-unique array of integers is valid",
"data": [
1,
1
],
"valid": true
},
{
"description": "numbers are unique if mathematically unequal",
"data": [
1.0,
1.0,
1
],
"valid": true
},
{
"description": "false is not equal to zero",
"data": [
0,
false
],
"valid": true
},
{
"description": "true is not equal to one",
"data": [
1,
true
],
"valid": true
},
{
"description": "unique array of objects is valid",
"data": [
{
"foo": "bar"
},
{
"foo": "baz"
}
],
"valid": true
},
{
"description": "non-unique array of objects is valid",
"data": [
{
"foo": "bar"
},
{
"foo": "bar"
}
],
"valid": true
},
{
"description": "unique array of nested objects is valid",
"data": [
{
"foo": {
"bar": {
"baz": true
}
}
},
{
"foo": {
"bar": {
"baz": false
}
}
}
],
"valid": true
},
{
"description": "non-unique array of nested objects is valid",
"data": [
{
"foo": {
"bar": {
"baz": true
}
}
},
{
"foo": {
"bar": {
"baz": true
}
}
}
],
"valid": true
},
{
"description": "unique array of arrays is valid",
"data": [
[
"foo"
],
[
"bar"
]
],
"valid": true
},
{
"description": "non-unique array of arrays is valid",
"data": [
[
"foo"
],
[
"foo"
]
],
"valid": true
},
{
"description": "1 and true are unique",
"data": [
1,
true
],
"valid": true
},
{
"description": "0 and false are unique",
"data": [
0,
false
],
"valid": true
},
{
"description": "unique heterogeneous types are valid",
"data": [
{},
[
1
],
true,
null,
1
],
"valid": true
},
{
"description": "non-unique heterogeneous types are valid",
"data": [
{},
[
1
],
true,
null,
{},
1
],
"valid": true
}
]
},
{
"description": "uniqueItems=false with an array of items",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [
{
"type": "boolean"
},
{
"type": "boolean"
}
],
"uniqueItems": false
},
"tests": [
{
"description": "[false, true] from items array is valid",
"data": [
false,
true
],
"valid": true
},
{
"description": "[true, false] from items array is valid",
"data": [
true,
false
],
"valid": true
},
{
"description": "[false, false] from items array is valid",
"data": [
false,
false
],
"valid": true
},
{
"description": "[true, true] from items array is valid",
"data": [
true,
true
],
"valid": true
}
]
},
{
"description": "zero fraction",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"uniqueItems": true
},
"tests": [
{
"description": "with fraction",
"data": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
-1,
-2,
-3,
-4,
-5,
-6,
-7,
-8,
-9,
-10,
2.0
],
"valid": false
},
{
"description": "without fraction",
"data": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
-1,
-2,
-3,
-4,
-5,
-6,
-7,
-8,
-9,
-10,
2
],
"valid": false
}
]
}
]

View File

@ -1,143 +0,0 @@
[
{
"description": "validation of binary-encoded media type documents with schema",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentEncoding": "base64",
"contentSchema": { "required": ["foo"], "properties": { "foo": { "type": "string" } } }
},
"tests": [
{
"description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K",
"valid": true
},
{
"description": "another valid base64-encoded JSON document",
"data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==",
"valid": true
},
{
"description": "an invalid base64-encoded JSON document; validates false",
"data": "eyJib28iOiAyMH0=",
"valid": false
},
{
"description": "an empty object as a base64-encoded JSON document; validates false",
"data": "e30=",
"valid": false
},
{
"description": "an empty array as a base64-encoded JSON document",
"data": "W10=",
"valid": true
},
{
"description": "a validly-encoded invalid JSON document; validates false",
"data": "ezp9Cg==",
"valid": false
},
{
"description": "an invalid base64 string that is valid JSON; validates false",
"data": "{}",
"valid": false
},
{
"description": "ignores non-strings",
"data": 100,
"valid": true
}
]
},
{
"description": "contentSchema without contentMediaType",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentEncoding": "base64",
"contentSchema": { "required": ["foo"], "properties": { "foo": { "type": "string" } } }
},
"tests": [
{
"description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K",
"valid": true
},
{
"description": "another valid base64-encoded JSON document",
"data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==",
"valid": true
},
{
"description": "an invalid base64-encoded JSON document; validates true",
"data": "eyJib28iOiAyMH0=",
"valid": true
},
{
"description": "an empty object as a base64-encoded JSON document; validates true",
"data": "e30=",
"valid": true
},
{
"description": "an empty array as a base64-encoded JSON document",
"data": "W10=",
"valid": true
},
{
"description": "a validly-encoded invalid JSON document; validates true",
"data": "ezp9Cg==",
"valid": true
},
{
"description": "an invalid base64 string that is valid JSON; validates false",
"data": "{}",
"valid": false
},
{
"description": "ignores non-strings",
"data": 100,
"valid": true
}
]
},
{
"description": "contentSchema without contentEncoding",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json",
"contentSchema": { "required": ["foo"], "properties": { "foo": { "type": "string" } } }
},
"tests": [
{
"description": "a valid JSON document",
"data": "{\"foo\": \"bar\"}",
"valid": true
},
{
"description": "another valid base64-encoded JSON document",
"data": "{\"boo\": 20, \"foo\": \"baz\"}",
"valid": true
},
{
"description": "an empty object; validates false",
"data": "{}",
"valid": false
},
{
"description": "an empty array; validates false",
"data": "[]",
"valid": true
},
{
"description": "invalid JSON document; validates false",
"data": "[}",
"valid": false
},
{
"description": "ignores non-strings",
"data": 100,
"valid": true
}
]
}
]

View File

@ -1,16 +0,0 @@
[
{
"description": "validation of date strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "date"
},
"tests": [
{
"description": "contains alphabets",
"data": "yyyy-mm-dd",
"valid": false
}
]
}
]

View File

@ -1,16 +0,0 @@
[
{
"description": "validation of duration strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "duration"
},
"tests": [
{
"description": "more than one T",
"data": "PT1MT1S",
"valid": false
}
]
}
]

View File

@ -1,31 +0,0 @@
[
{
"description": "validation of duration strings",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "email"
},
"tests": [
{
"description": "non printable character",
"data": "a\tb@gmail.com",
"valid": false
},
{
"description": "tab ok if quoted",
"data": "\"a\tb\"@gmail.com",
"valid": true
},
{
"description": "quote inside quoted",
"data": "\"a\"b\"@gmail.com",
"valid": false
},
{
"description": "backslash inside quoted",
"data": "\"a\\b\"@gmail.com",
"valid": false
}
]
}
]

View File

@ -1,23 +0,0 @@
[
{
"description": "validation of time strings",
"schema": { "format": "time" },
"tests": [
{
"description": "contains alphabets",
"data": "ab:cd:efZ",
"valid": false
},
{
"description": "no digit in second fraction",
"data": "23:20:50.Z",
"valid": false
},
{
"description": "alphabets in offset",
"data": "08:30:06+ab:cd",
"valid": false
}
]
}
]

View File

@ -277,9 +277,9 @@
"valid": false
},
{
"description": "an empty string is not a boolean",
"description": "an empty string is a null",
"data": "",
"valid": false
"valid": true
},
{
"description": "an object is not a boolean",
@ -336,9 +336,9 @@
"valid": false
},
{
"description": "an empty string is not null",
"description": "an empty string is null",
"data": "",
"valid": false
"valid": true
},
{
"description": "an object is not null",