diff options
author | Julian Berman <Julian@GrayVines.com> | 2020-05-02 16:04:17 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2020-05-02 16:04:17 -0400 |
commit | 1fae89b3cec5c018e86a8aa14f394543fd18d2d6 (patch) | |
tree | 091aeb6515aab8f55ea5371d15547ba97ecad204 /json | |
parent | 8a0563cd9ccedd0ee46b84f8e8e386bcd0e1f51e (diff) | |
parent | f40e3aa7cd52d4da653f86f40fe3aeb55d872975 (diff) | |
download | jsonschema-1fae89b3cec5c018e86a8aa14f394543fd18d2d6.tar.gz |
Merge commit 'f40e3aa7cd52d4da653f86f40fe3aeb55d872975'
* commit 'f40e3aa7cd52d4da653f86f40fe3aeb55d872975':
Squashed 'json/' changes from 71f55b36b..361620ecf
Diffstat (limited to 'json')
20 files changed, 1343 insertions, 480 deletions
diff --git a/json/.github/workflows/ci.yml b/json/.github/workflows/ci.yml index 83d3040..9fdb508 100644 --- a/json/.github/workflows/ci.yml +++ b/json/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: 3.7 - name: Install tox diff --git a/json/README.md b/json/README.md index 9d802cc..5c393d6 100644 --- a/json/README.md +++ b/json/README.md @@ -12,16 +12,16 @@ choice is still the job of the validator implementor. Structure of a Test ------------------- -If you're going to use this suite, you need to know how tests are laid out. The -tests are contained in the `tests` directory at the root of this repository. +The tests in this suite are contained in the `tests` directory at the +root of this repository. Inside that directory is a subdirectory for each draft or version of the -schema. +specification. -If you look inside the draft directory, there are a number of `.json` files, -which logically group a set of test cases together. Often the grouping is by -property under test, but not always, especially within optional test files -(discussed below). +Inside each draft directory, there are a number of `.json` files, which +logically group a set of test cases together. Often the grouping is by +property under test, but not always, especially within optional test +files (discussed below). Inside each `.json` file is a single array containing objects. It's easiest to illustrate the structure of these with an example: @@ -45,9 +45,10 @@ illustrate the structure of these with an example: } ``` -So a description, a schema, and some tests, where tests is an array containing -one or more objects with descriptions, data, and a boolean indicating whether -they should be valid or invalid. +In short: a description, a schema under test, and some tests, where each +test in the `tests` array is an objects with a description of the case +itself, the instance under test, and a boolean indicating whether it +should be valid or invalid. Coverage -------- @@ -59,9 +60,6 @@ Draft 2019-09 support is under development. Contributions are very welcome, especially from implementers as they add support to their own implementations. -Bug fixes will be made as needed for draft-04 as it is still the most -widely used, while draft-03 is long since deprecated. - If you see anything missing from the current supported drafts, or incorrect on any draft still accepting bug fixes, please file an issue or submit a PR. diff --git a/json/test-schema.json b/json/test-schema.json index d5fe538..877d381 100644 --- a/json/test-schema.json +++ b/json/test-schema.json @@ -11,7 +11,14 @@ "type": "string", "format": "uri" }, - "description": { "type": "string" }, + "description": { + "description": "The test set description", + "type": "string" + }, + "comment": { + "description": "Any additional comments about the test set", + "type": "string" + }, "schema": { "description": "This should be a valid schema. This should be a ref to a meta-schema if schema keywords need testing." }, @@ -56,7 +63,14 @@ "type": "string", "format": "uri" }, - "description": { "type": "string" }, + "description": { + "description": "The test description", + "type": "string" + }, + "comment": { + "description": "Any additional comments about the test", + "type": "string" + }, "data": {}, "valid": { "type": "boolean" }, "output": { diff --git a/json/tests/draft2019-09/optional/non-bmp-regex.json b/json/tests/draft2019-09/optional/non-bmp-regex.json new file mode 100644 index 0000000..dd67af2 --- /dev/null +++ b/json/tests/draft2019-09/optional/non-bmp-regex.json @@ -0,0 +1,82 @@ +[ + { + "description": "Proper UTF-16 surrogate pair handling: pattern", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { "pattern": "^🐲*$" }, + "tests": [ + { + "description": "matches empty", + "data": "", + "valid": true + }, + { + "description": "matches single", + "data": "🐲", + "valid": true + }, + { + "description": "matches two", + "data": "🐲🐲", + "valid": true + }, + { + "description": "doesn't match one", + "data": "🐉", + "valid": false + }, + { + "description": "doesn't match two", + "data": "🐉🐉", + "valid": false + }, + { + "description": "doesn't match one ASCII", + "data": "D", + "valid": false + }, + { + "description": "doesn't match two ASCII", + "data": "DD", + "valid": false + } + ] + }, + { + "description": "Proper UTF-16 surrogate pair handling: patternProperties", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { + "patternProperties": { + "^🐲*$": { + "type": "integer" + } + } + }, + "tests": [ + { + "description": "matches empty", + "data": { "": 1 }, + "valid": true + }, + { + "description": "matches single", + "data": { "🐲": 1 }, + "valid": true + }, + { + "description": "matches two", + "data": { "🐲🐲": 1 }, + "valid": true + }, + { + "description": "doesn't match one", + "data": { "🐲": "hello" }, + "valid": false + }, + { + "description": "doesn't match two", + "data": { "🐲🐲": "hello" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft2019-09/pattern.json b/json/tests/draft2019-09/pattern.json index 3c7e04c..92db0f9 100644 --- a/json/tests/draft2019-09/pattern.json +++ b/json/tests/draft2019-09/pattern.json @@ -55,46 +55,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { "pattern": "^🐲*$" }, - "tests": [ - { - "description": "matches empty", - "data": "", - "valid": true - }, - { - "description": "matches single", - "data": "🐲", - "valid": true - }, - { - "description": "matches two", - "data": "🐲🐲", - "valid": true - }, - { - "description": "doesn't match one", - "data": "🐉", - "valid": false - }, - { - "description": "doesn't match two", - "data": "🐉🐉", - "valid": false - }, - { - "description": "doesn't match one ASCII", - "data": "D", - "valid": false - }, - { - "description": "doesn't match two ASCII", - "data": "DD", - "valid": false - } - ] } ] diff --git a/json/tests/draft2019-09/patternProperties.json b/json/tests/draft2019-09/patternProperties.json index 290cfc4..1d04a16 100644 --- a/json/tests/draft2019-09/patternProperties.json +++ b/json/tests/draft2019-09/patternProperties.json @@ -147,42 +147,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { - "patternProperties": { - "^🐲*$": { - "type": "integer" - } - } - }, - "tests": [ - { - "description": "matches empty", - "data": { "": 1 }, - "valid": true - }, - { - "description": "matches single", - "data": { "🐲": 1 }, - "valid": true - }, - { - "description": "matches two", - "data": { "🐲🐲": 1 }, - "valid": true - }, - { - "description": "doesn't match one", - "data": { "🐲": "hello" }, - "valid": false - }, - { - "description": "doesn't match two", - "data": { "🐲🐲": "hello" }, - "valid": false - } - ] } ] diff --git a/json/tests/draft2019-09/unevaluatedItems.json b/json/tests/draft2019-09/unevaluatedItems.json index 54b686e..de285b0 100644 --- a/json/tests/draft2019-09/unevaluatedItems.json +++ b/json/tests/draft2019-09/unevaluatedItems.json @@ -1,85 +1,415 @@ [ { - "description": "anyOf with false unevaluatedItems", + "description": "unevaluatedItems true", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "unevaluatedItems": false, - "anyOf": [ - {"items": {"type": "string"}}, - {"items": [true, true]} - ] + "type": "array", + "unevaluatedItems": true }, "tests": [ { - "description": "all strings is valid", - "data": ["foo", "bar", "baz"], + "description": "with no unevaluated items", + "data": [], "valid": true }, { - "description": "one item is valid", - "data": [1], + "description": "with unevaluated items", + "data": ["foo"], + "valid": true + } + ] + }, + { + "description": "unevaluatedItems false", + "schema": { + "type": "array", + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": [], "valid": true }, { - "description": "two items are valid", - "data": [1, "two"], + "description": "with unevaluated items", + "data": ["foo"], + "valid": false + } + ] + }, + { + "description": "unevaluatedItems as schema", + "schema": { + "type": "array", + "unevaluatedItems": { "type": "string" } + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": [], + "valid": true + }, + { + "description": "with valid unevaluated items", + "data": ["foo"], "valid": true }, { - "description": "three items are invalid", - "data": [1, "two", "three"], + "description": "with invalid unevaluated items", + "data": [42], "valid": false + } + ] + }, + { + "description": "unevaluatedItems with uniform items", + "schema": { + "type": "array", + "items": { "type": "string" }, + "unevaluatedItems": false + }, + "tests": [ + { + "description": "unevaluatedItems doesn't apply", + "data": ["foo", "bar"], + "valid": true + } + ] + }, + { + "description": "unevaluatedItems with tuple", + "schema": { + "type": "array", + "items": [ + { "type": "string" } + ], + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluted items", + "data": ["foo"], + "valid": true }, { - "description": "four strings are valid", - "data": ["one", "two", "three", "four"], + "description": "with unevaluted items", + "data": ["foo", "bar"], + "valid": false + } + ] + }, + { + "description": "unevaluatedItems with additionalItems", + "schema": { + "type": "array", + "items": [ + { "type": "string" } + ], + "additionalItems": true, + "unevaluatedItems": false + }, + "tests": [ + { + "description": "unevaluatedItems doesn't apply", + "data": ["foo", 42], "valid": true } ] }, { - "description": "complex unevaluated schema", + "description": "unevaluatedItems with nested tuple", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "unevaluatedItems": { - "allOf": [{"minLength": 3}, {"type": "string"}] + "type": "array", + "items": [ + { "type": "string" } + ], + "allOf": [ + { + "items": [ + true, + { "type": "number" } + ] + } + ], + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluted items", + "data": ["foo", 42], + "valid": true }, - "if": {"items": [{"type": "integer"}, {"type": "array"}]} + { + "description": "with unevaluted items", + "data": ["foo", 42, true], + "valid": false + } + ] + }, + { + "description": "unevaluatedItems with nested additionalItems", + "schema": { + "type": "array", + "allOf": [ + { + "items": [ + { "type": "string" } + ], + "additionalItems": true + } + ], + "unevaluatedItems": false }, "tests": [ { - "description": "empty array", - "data": [], + "description": "with no additional items", + "data": ["foo"], + "valid": true + }, + { + "description": "with additional items", + "data": ["foo", 42, true], + "valid": true + } + ] + }, + { + "description": "unevaluatedItems with nested unevaluatedItems", + "schema": { + "type": "array", + "allOf": [ + { + "items": [ + { "type": "string" } + ] + }, + { + "unevaluatedItems": true + } + ], + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no additional items", + "data": ["foo"], "valid": true }, { - "description": "if passes with one item", - "data": [1], + "description": "with additional items", + "data": ["foo", 42, true], + "valid": true + } + ] + }, + { + "description": "unevaluatedItems with anyOf", + "schema": { + "type": "array", + "items": [ + { "const": "foo" } + ], + "anyOf": [ + { + "items": [ + true, + { "const": "bar" } + ] + }, + { + "items": [ + true, + true, + { "const": "baz" } + ] + } + ], + "unevaluatedItems": false + }, + "tests": [ + { + "description": "when one schema matches and has no unevaluted items", + "data": ["foo", "bar"], "valid": true }, { - "description": "if passes with two items", - "data": [1, [2, 3]], + "description": "when one schema matches and has unevaluted items", + "data": ["foo", "bar", 42], + "valid": false + }, + { + "description": "when two schemas match and has no unevaluted items", + "data": ["foo", "bar", "baz"], "valid": true }, { - "description": "if passes with third valid unevaluated item", - "data": [1, [2, 3], "long-string"], + "description": "when two schemas match and has unevaluted items", + "data": ["foo", "bar", "baz", 42], + "valid": false + } + ] + }, + { + "description": "unevaluatedItems with oneOf", + "schema": { + "type": "array", + "items": [ + { "const": "foo" } + ], + "oneOf": [ + { + "items": [ + true, + { "const": "bar" } + ] + }, + { + "items": [ + true, + { "const": "baz" } + ] + } + ], + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluted items", + "data": ["foo", "bar"], "valid": true }, { - "description": "if passes with third invalid unevaluated item", - "data": [1, [2, 3], "zz"], + "description": "with unevaluted items", + "data": ["foo", "bar", 42], "valid": false + } + ] + }, + { + "description": "unevaluatedItems with not", + "schema": { + "type": "array", + "items": [ + { "const": "foo" } + ], + "not": { + "not": { + "items": [ + true, + { "const": "bar" } + ] + } }, + "unevaluatedItems": false + }, + "tests": [ { - "description": "if fails with all valid unevaluated items", - "data": ["all", "long", "strings"], + "description": "with unevaluted items", + "data": ["foo", "bar"], + "valid": false + } + ] + }, + { + "description": "unevaluatedItems with if/then/else", + "schema": { + "type": "array", + "items": [ + { "const": "foo" } + ], + "if": { + "items": [ + true, + { "const": "bar" } + ] + }, + "then": { + "items": [ + true, + true, + { "const": "then" } + ] + }, + "else": { + "items": [ + true, + true, + true, + { "const": "else" } + ] + }, + "unevaluatedItems": false + }, + "tests": [ + { + "description": "when if matches and it has no unevaluted items", + "data": ["foo", "bar", "then"], + "valid": true + }, + { + "description": "when if matches and it has unevaluted items", + "data": ["foo", "bar", "then", "else"], + "valid": false + }, + { + "description": "when if doesn't match and it has no unevaluted items", + "data": ["foo", 42, 42, "else"], + "valid": true + }, + { + "description": "when if doesn't match and it has unevaluted items", + "data": ["foo", 42, 42, "else", 42], + "valid": false + } + ] + }, + { + "description": "unevaluatedItems with boolean schemas", + "schema": { + "type": "array", + "allOf": [true], + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": [], "valid": true }, { - "description": "if and unevaluated items fail", - "data": ["a", "b", "c"], + "description": "with unevaluated items", + "data": ["foo"], + "valid": false + } + ] + }, + { + "description": "unevaluatedItems with $ref", + "schema": { + "type": "array", + "$ref": "#/$defs/bar", + "items": [ + { "type": "string" } + ], + "unevaluatedItems": false, + "$defs": { + "bar": { + "items": [ + true, + { "type": "string" } + ] + } + } + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": ["foo", "bar"], + "valid": true + }, + { + "description": "with unevaluated items", + "data": ["foo", "bar", "baz"], "valid": false } ] diff --git a/json/tests/draft2019-09/unevaluatedProperties.json b/json/tests/draft2019-09/unevaluatedProperties.json index 2d999ce..bae54cc 100644 --- a/json/tests/draft2019-09/unevaluatedProperties.json +++ b/json/tests/draft2019-09/unevaluatedProperties.json @@ -1,90 +1,591 @@ [ { - "description": "allOf with false unevaluatedProperties", + "description": "unevaluatedProperties true", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "unevaluatedProperties": false, + "type": "object", + "unevaluatedProperties": true + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": {}, + "valid": true + }, + { + "description": "with unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + } + ] + }, + { + "description": "unevaluatedProperties schema", + "schema": { + "type": "object", + "unevaluatedProperties": { + "type": "string", + "minLength": 3 + } + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": {}, + "valid": true + }, + { + "description": "with valid unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with invalid unevaluated properties", + "data": { + "foo": "fo" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties false", + "schema": { + "type": "object", + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": {}, + "valid": true + }, + { + "description": "with unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with adjacent properties", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with adjacent patternProperties", + "schema": { + "type": "object", + "patternProperties": { + "^foo": { "type": "string" } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with adjacent additionalProperties", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "additionalProperties": true, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no additional properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with additional properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + } + ] + }, + { + "description": "unevaluatedProperties with nested properties", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, "allOf": [ { "properties": { - "foo": { "type": ["string", "null"] }, - "bar": { "type": ["string", "null"] } + "bar": { "type": "string" } } + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no additional properties", + "data": { + "foo": "foo", + "bar": "bar" }, + "valid": true + }, + { + "description": "with additional properties", + "data": { + "foo": "foo", + "bar": "bar", + "baz": "baz" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with nested patternProperties", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "allOf": [ + { + "patternProperties": { + "^bar": { "type": "string" } + } + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no additional properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + }, + { + "description": "with additional properties", + "data": { + "foo": "foo", + "bar": "bar", + "baz": "baz" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with nested additionalProperties", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "allOf": [ { - "additionalProperties": { - "not": { "enum": [ null ] } - } + "additionalProperties": true + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no additional properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with additional properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + } + ] + }, + { + "description": "unevaluatedProperties with nested unevaluatedProperties", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "allOf": [ + { + "unevaluatedProperties": true + } + ], + "unevaluatedProperties": { + "type": "string", + "maxLength": 2 + } + }, + "tests": [ + { + "description": "with no nested unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with nested unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + } + ] + }, + { + "description": "unevaluatedProperties with anyOf", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "anyOf": [ + { + "properties": { + "bar": { "const": "bar" } + }, + "required": ["bar"] + }, + { + "properties": { + "baz": { "const": "baz" } + }, + "required": ["baz"] + }, + { + "properties": { + "quux": { "const": "quux" } + }, + "required": ["quux"] } - ] + ], + "unevaluatedProperties": false }, "tests": [ { - "description": "string props valid", - "data": { "bar": "foo", "bob": "who?" }, + "description": "when one matches and has no unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, "valid": true }, { - "description": "null prop is invalid", - "data": { "bar": "foo", "bob": null }, + "description": "when one matches and has unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar", + "baz": "not-baz" + }, "valid": false }, { - "description": "named property with wrong type is invalid", - "data": { "bar": "foo", "bob": "who?" }, - "valid": true + "description": "when two match and has no unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar", + "baz": "baz" + }, + "valid": true + }, + { + "description": "when two match and has unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar", + "baz": "baz", + "quux": "not-quux" + }, + "valid": false } ] }, { - "description": "complex unevaluated schema", + "description": "unevaluatedProperties with oneOf", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "unevaluatedProperties": { - "allOf": [{"minLength": 3}, {"type": "string"}] + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "oneOf": [ + { + "properties": { + "bar": { "const": "bar" } + }, + "required": ["bar"] + }, + { + "properties": { + "baz": { "const": "baz" } + }, + "required": ["baz"] + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true }, + { + "description": "with unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar", + "quux": "quux" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with not", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "not": { + "not": { + "properties": { + "bar": { "const": "bar" } + }, + "required": ["bar"] + } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with if/then/else", + "schema": { + "type": "object", "if": { - "properties": { - "foo": {"type": "integer"}, - "arr": {"type": "array"} + "properties": { + "foo": { "const": "then" } }, "required": ["foo"] - } + }, + "then": { + "properties": { + "bar": { "type": "string" } + }, + "required": ["bar"] + }, + "else": { + "properties": { + "baz": { "type": "string" } + }, + "required": ["baz"] + }, + "unevaluatedProperties": false }, "tests": [ { - "description": "empty object", - "data": {}, + "description": "when if is true and has no unevaluated properties", + "data": { + "foo": "then", + "bar": "bar" + }, "valid": true }, { - "description": "if passes", - "data": {"foo": 3, "arr": [1,2]}, + "description": "when if is true and has unevaluated properties", + "data": { + "foo": "then", + "bar": "bar", + "baz": "baz" + }, + "valid": false + }, + { + "description": "when if is false and has no unevaluated properties", + "data": { + "baz": "baz" + }, "valid": true }, { - "description": "if passes with valid uneval", - "data": {"foo": 3, "arr": [1,2], "uneval": "long-string"}, + "description": "when if is false and has unevaluated properties", + "data": { + "foo": "else", + "baz": "baz" + }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with dependentSchemas", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": { "const": "bar" } + }, + "required": ["bar"] + } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, "valid": true }, { - "description": "if passes with invalid short uneval", - "data": {"foo": 3, "arr": [1,2], "uneval": "zz"}, + "description": "with unevaluated properties", + "data": { + "bar": "bar" + }, "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with boolean schemas", + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" } }, + "allOf": [true], + "unevaluatedProperties": false + }, + "tests": [ { - "description": "if fails, and uneval fails because of array", - "data": {"foo": "not-an-int", "arr": [1,2], "uneval": "long-string"}, + "description": "with no unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with unevaluated properties", + "data": { + "bar": "bar" + }, "valid": false + } + ] + }, + { + "description": "unevaluatedProperties with $ref", + "schema": { + "type": "object", + "$ref": "#/$defs/bar", + "properties": { + "foo": { "type": "string" } }, + "unevaluatedProperties": false, + "$defs": { + "bar": { + "properties": { + "bar": { "type": "string" } + } + } + } + }, + "tests": [ { - "description": "if fails with valid uneval", - "data": {"foo": "not-an-int", "uneval": "long-string"}, + "description": "with no unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar" + }, "valid": true }, { - "description": "if fails with invalid uneval", - "data": {"foo": "zz", "uneval": "long-string"}, + "description": "with unevaluated properties", + "data": { + "foo": "foo", + "bar": "bar", + "baz": "baz" + }, "valid": false } ] diff --git a/json/tests/draft3/optional/non-bmp-regex.json b/json/tests/draft3/optional/non-bmp-regex.json new file mode 100644 index 0000000..dd67af2 --- /dev/null +++ b/json/tests/draft3/optional/non-bmp-regex.json @@ -0,0 +1,82 @@ +[ + { + "description": "Proper UTF-16 surrogate pair handling: pattern", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { "pattern": "^🐲*$" }, + "tests": [ + { + "description": "matches empty", + "data": "", + "valid": true + }, + { + "description": "matches single", + "data": "🐲", + "valid": true + }, + { + "description": "matches two", + "data": "🐲🐲", + "valid": true + }, + { + "description": "doesn't match one", + "data": "🐉", + "valid": false + }, + { + "description": "doesn't match two", + "data": "🐉🐉", + "valid": false + }, + { + "description": "doesn't match one ASCII", + "data": "D", + "valid": false + }, + { + "description": "doesn't match two ASCII", + "data": "DD", + "valid": false + } + ] + }, + { + "description": "Proper UTF-16 surrogate pair handling: patternProperties", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { + "patternProperties": { + "^🐲*$": { + "type": "integer" + } + } + }, + "tests": [ + { + "description": "matches empty", + "data": { "": 1 }, + "valid": true + }, + { + "description": "matches single", + "data": { "🐲": 1 }, + "valid": true + }, + { + "description": "matches two", + "data": { "🐲🐲": 1 }, + "valid": true + }, + { + "description": "doesn't match one", + "data": { "🐲": "hello" }, + "valid": false + }, + { + "description": "doesn't match two", + "data": { "🐲🐲": "hello" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft3/pattern.json b/json/tests/draft3/pattern.json index 3c7e04c..92db0f9 100644 --- a/json/tests/draft3/pattern.json +++ b/json/tests/draft3/pattern.json @@ -55,46 +55,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { "pattern": "^🐲*$" }, - "tests": [ - { - "description": "matches empty", - "data": "", - "valid": true - }, - { - "description": "matches single", - "data": "🐲", - "valid": true - }, - { - "description": "matches two", - "data": "🐲🐲", - "valid": true - }, - { - "description": "doesn't match one", - "data": "🐉", - "valid": false - }, - { - "description": "doesn't match two", - "data": "🐉🐉", - "valid": false - }, - { - "description": "doesn't match one ASCII", - "data": "D", - "valid": false - }, - { - "description": "doesn't match two ASCII", - "data": "DD", - "valid": false - } - ] } ] diff --git a/json/tests/draft3/patternProperties.json b/json/tests/draft3/patternProperties.json index 3a39983..2ca9aae 100644 --- a/json/tests/draft3/patternProperties.json +++ b/json/tests/draft3/patternProperties.json @@ -111,42 +111,5 @@ "valid": false } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { - "patternProperties": { - "^🐲*$": { - "type": "integer" - } - } - }, - "tests": [ - { - "description": "matches empty", - "data": { "": 1 }, - "valid": true - }, - { - "description": "matches single", - "data": { "🐲": 1 }, - "valid": true - }, - { - "description": "matches two", - "data": { "🐲🐲": 1 }, - "valid": true - }, - { - "description": "doesn't match one", - "data": { "🐲": "hello" }, - "valid": false - }, - { - "description": "doesn't match two", - "data": { "🐲🐲": "hello" }, - "valid": false - } - ] } ] diff --git a/json/tests/draft4/optional/non-bmp-regex.json b/json/tests/draft4/optional/non-bmp-regex.json new file mode 100644 index 0000000..dd67af2 --- /dev/null +++ b/json/tests/draft4/optional/non-bmp-regex.json @@ -0,0 +1,82 @@ +[ + { + "description": "Proper UTF-16 surrogate pair handling: pattern", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { "pattern": "^🐲*$" }, + "tests": [ + { + "description": "matches empty", + "data": "", + "valid": true + }, + { + "description": "matches single", + "data": "🐲", + "valid": true + }, + { + "description": "matches two", + "data": "🐲🐲", + "valid": true + }, + { + "description": "doesn't match one", + "data": "🐉", + "valid": false + }, + { + "description": "doesn't match two", + "data": "🐉🐉", + "valid": false + }, + { + "description": "doesn't match one ASCII", + "data": "D", + "valid": false + }, + { + "description": "doesn't match two ASCII", + "data": "DD", + "valid": false + } + ] + }, + { + "description": "Proper UTF-16 surrogate pair handling: patternProperties", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { + "patternProperties": { + "^🐲*$": { + "type": "integer" + } + } + }, + "tests": [ + { + "description": "matches empty", + "data": { "": 1 }, + "valid": true + }, + { + "description": "matches single", + "data": { "🐲": 1 }, + "valid": true + }, + { + "description": "matches two", + "data": { "🐲🐲": 1 }, + "valid": true + }, + { + "description": "doesn't match one", + "data": { "🐲": "hello" }, + "valid": false + }, + { + "description": "doesn't match two", + "data": { "🐲🐲": "hello" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft4/pattern.json b/json/tests/draft4/pattern.json index 3c7e04c..92db0f9 100644 --- a/json/tests/draft4/pattern.json +++ b/json/tests/draft4/pattern.json @@ -55,46 +55,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { "pattern": "^🐲*$" }, - "tests": [ - { - "description": "matches empty", - "data": "", - "valid": true - }, - { - "description": "matches single", - "data": "🐲", - "valid": true - }, - { - "description": "matches two", - "data": "🐲🐲", - "valid": true - }, - { - "description": "doesn't match one", - "data": "🐉", - "valid": false - }, - { - "description": "doesn't match two", - "data": "🐉🐉", - "valid": false - }, - { - "description": "doesn't match one ASCII", - "data": "D", - "valid": false - }, - { - "description": "doesn't match two ASCII", - "data": "DD", - "valid": false - } - ] } ] diff --git a/json/tests/draft4/patternProperties.json b/json/tests/draft4/patternProperties.json index bdda1d7..5f741df 100644 --- a/json/tests/draft4/patternProperties.json +++ b/json/tests/draft4/patternProperties.json @@ -116,42 +116,5 @@ "valid": false } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { - "patternProperties": { - "^🐲*$": { - "type": "integer" - } - } - }, - "tests": [ - { - "description": "matches empty", - "data": { "": 1 }, - "valid": true - }, - { - "description": "matches single", - "data": { "🐲": 1 }, - "valid": true - }, - { - "description": "matches two", - "data": { "🐲🐲": 1 }, - "valid": true - }, - { - "description": "doesn't match one", - "data": { "🐲": "hello" }, - "valid": false - }, - { - "description": "doesn't match two", - "data": { "🐲🐲": "hello" }, - "valid": false - } - ] } ] diff --git a/json/tests/draft6/optional/non-bmp-regex.json b/json/tests/draft6/optional/non-bmp-regex.json new file mode 100644 index 0000000..dd67af2 --- /dev/null +++ b/json/tests/draft6/optional/non-bmp-regex.json @@ -0,0 +1,82 @@ +[ + { + "description": "Proper UTF-16 surrogate pair handling: pattern", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { "pattern": "^🐲*$" }, + "tests": [ + { + "description": "matches empty", + "data": "", + "valid": true + }, + { + "description": "matches single", + "data": "🐲", + "valid": true + }, + { + "description": "matches two", + "data": "🐲🐲", + "valid": true + }, + { + "description": "doesn't match one", + "data": "🐉", + "valid": false + }, + { + "description": "doesn't match two", + "data": "🐉🐉", + "valid": false + }, + { + "description": "doesn't match one ASCII", + "data": "D", + "valid": false + }, + { + "description": "doesn't match two ASCII", + "data": "DD", + "valid": false + } + ] + }, + { + "description": "Proper UTF-16 surrogate pair handling: patternProperties", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { + "patternProperties": { + "^🐲*$": { + "type": "integer" + } + } + }, + "tests": [ + { + "description": "matches empty", + "data": { "": 1 }, + "valid": true + }, + { + "description": "matches single", + "data": { "🐲": 1 }, + "valid": true + }, + { + "description": "matches two", + "data": { "🐲🐲": 1 }, + "valid": true + }, + { + "description": "doesn't match one", + "data": { "🐲": "hello" }, + "valid": false + }, + { + "description": "doesn't match two", + "data": { "🐲🐲": "hello" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft6/pattern.json b/json/tests/draft6/pattern.json index 3c7e04c..92db0f9 100644 --- a/json/tests/draft6/pattern.json +++ b/json/tests/draft6/pattern.json @@ -55,46 +55,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { "pattern": "^🐲*$" }, - "tests": [ - { - "description": "matches empty", - "data": "", - "valid": true - }, - { - "description": "matches single", - "data": "🐲", - "valid": true - }, - { - "description": "matches two", - "data": "🐲🐲", - "valid": true - }, - { - "description": "doesn't match one", - "data": "🐉", - "valid": false - }, - { - "description": "doesn't match two", - "data": "🐉🐉", - "valid": false - }, - { - "description": "doesn't match one ASCII", - "data": "D", - "valid": false - }, - { - "description": "doesn't match two ASCII", - "data": "DD", - "valid": false - } - ] } ] diff --git a/json/tests/draft6/patternProperties.json b/json/tests/draft6/patternProperties.json index 290cfc4..1d04a16 100644 --- a/json/tests/draft6/patternProperties.json +++ b/json/tests/draft6/patternProperties.json @@ -147,42 +147,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { - "patternProperties": { - "^🐲*$": { - "type": "integer" - } - } - }, - "tests": [ - { - "description": "matches empty", - "data": { "": 1 }, - "valid": true - }, - { - "description": "matches single", - "data": { "🐲": 1 }, - "valid": true - }, - { - "description": "matches two", - "data": { "🐲🐲": 1 }, - "valid": true - }, - { - "description": "doesn't match one", - "data": { "🐲": "hello" }, - "valid": false - }, - { - "description": "doesn't match two", - "data": { "🐲🐲": "hello" }, - "valid": false - } - ] } ] diff --git a/json/tests/draft7/optional/non-bmp-regex.json b/json/tests/draft7/optional/non-bmp-regex.json new file mode 100644 index 0000000..dd67af2 --- /dev/null +++ b/json/tests/draft7/optional/non-bmp-regex.json @@ -0,0 +1,82 @@ +[ + { + "description": "Proper UTF-16 surrogate pair handling: pattern", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { "pattern": "^🐲*$" }, + "tests": [ + { + "description": "matches empty", + "data": "", + "valid": true + }, + { + "description": "matches single", + "data": "🐲", + "valid": true + }, + { + "description": "matches two", + "data": "🐲🐲", + "valid": true + }, + { + "description": "doesn't match one", + "data": "🐉", + "valid": false + }, + { + "description": "doesn't match two", + "data": "🐉🐉", + "valid": false + }, + { + "description": "doesn't match one ASCII", + "data": "D", + "valid": false + }, + { + "description": "doesn't match two ASCII", + "data": "DD", + "valid": false + } + ] + }, + { + "description": "Proper UTF-16 surrogate pair handling: patternProperties", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { + "patternProperties": { + "^🐲*$": { + "type": "integer" + } + } + }, + "tests": [ + { + "description": "matches empty", + "data": { "": 1 }, + "valid": true + }, + { + "description": "matches single", + "data": { "🐲": 1 }, + "valid": true + }, + { + "description": "matches two", + "data": { "🐲🐲": 1 }, + "valid": true + }, + { + "description": "doesn't match one", + "data": { "🐲": "hello" }, + "valid": false + }, + { + "description": "doesn't match two", + "data": { "🐲🐲": "hello" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft7/pattern.json b/json/tests/draft7/pattern.json index 3c7e04c..92db0f9 100644 --- a/json/tests/draft7/pattern.json +++ b/json/tests/draft7/pattern.json @@ -55,46 +55,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { "pattern": "^🐲*$" }, - "tests": [ - { - "description": "matches empty", - "data": "", - "valid": true - }, - { - "description": "matches single", - "data": "🐲", - "valid": true - }, - { - "description": "matches two", - "data": "🐲🐲", - "valid": true - }, - { - "description": "doesn't match one", - "data": "🐉", - "valid": false - }, - { - "description": "doesn't match two", - "data": "🐉🐉", - "valid": false - }, - { - "description": "doesn't match one ASCII", - "data": "D", - "valid": false - }, - { - "description": "doesn't match two ASCII", - "data": "DD", - "valid": false - } - ] } ] diff --git a/json/tests/draft7/patternProperties.json b/json/tests/draft7/patternProperties.json index 290cfc4..1d04a16 100644 --- a/json/tests/draft7/patternProperties.json +++ b/json/tests/draft7/patternProperties.json @@ -147,42 +147,5 @@ "valid": true } ] - }, - { - "description": "non-BMP, checks for proper surrogate pair handling for UTF-16", - "schema": { - "patternProperties": { - "^🐲*$": { - "type": "integer" - } - } - }, - "tests": [ - { - "description": "matches empty", - "data": { "": 1 }, - "valid": true - }, - { - "description": "matches single", - "data": { "🐲": 1 }, - "valid": true - }, - { - "description": "matches two", - "data": { "🐲🐲": 1 }, - "valid": true - }, - { - "description": "doesn't match one", - "data": { "🐲": "hello" }, - "valid": false - }, - { - "description": "doesn't match two", - "data": { "🐲🐲": "hello" }, - "valid": false - } - ] } ] |