diff options
author | Julian Berman <Julian@GrayVines.com> | 2023-04-25 17:09:24 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2023-04-25 17:09:24 -0400 |
commit | b695cd7efa3e40fc41721792b4a692436b9eca39 (patch) | |
tree | 369ced047425247a032d2c811f3c2730179d3f82 /tests | |
parent | c8c0bdd52999e4e1a6a38ceca814d0943f3e7962 (diff) | |
download | jsonschema-b695cd7efa3e40fc41721792b4a692436b9eca39.tar.gz |
Squashed 'json/' changes from 0788c226a..6afa9b38d
6afa9b38d Merge pull request #664 from santhosh-tekuri/empty-tokens
e4bceb1ad Bump the python-jsonschema version used for the sanity check.
8025fc0d5 Merge pull request #128 from iainbeeston/foundations-of-json-schema-paper
cf7677078 Make all root $ids absolute URIs
07fd389a3 Added test cases from Foundations of JSON Schema research paper
1008edcee ref: test empty tokens in json-pointer
9beb3cfba Merge pull request #627 from json-schema-org/ether/output-readme-fixes
f2b0490ba minor edit to trigger gh action
c305ce54f Merge pull request #669 from hauner/typo
5e2845c1e Merge pull request #668 from hauner/if-without-then-else-creates-annotations
2f1df2293 typo
c1fae0022 test unevaluated* can see annotations from if without then/else
987a4c8fc Merge pull request #666 from json-schema-org/gregsdennis/file-refs
90b2a58ce fix *nix uris
68d18c6ac rename tests to fix sanity check
e9166bcbe fix indentation
1d1ec749a add file-id ref tests
fb60ed17c Merge pull request #663 from json-schema-org/ether/restore-format-tests
f32cd8b80 Revert "Revert "by default, "format" only annotates, not validates""
47958f82d Merge pull request #654 from santhosh-tekuri/output-escape
5262997e1 Merge pull request #661 from santhosh-tekuri/2019-output
ce2c16573 output-tests: correct 2019 output-schema.json
c9d943856 output: ensure ~ and / are escaped in json-pointer
f6b2324bf minor spelling and markdown formatting fixes; `valid` has also been removed from the tests
git-subtree-dir: json
git-subtree-split: 6afa9b38d84d45550ec703123eb4e8ec67a8ae75
Diffstat (limited to 'tests')
27 files changed, 1143 insertions, 50 deletions
diff --git a/tests/draft-next/dependentSchemas.json b/tests/draft-next/dependentSchemas.json index 67c7979..8a84775 100644 --- a/tests/draft-next/dependentSchemas.json +++ b/tests/draft-next/dependentSchemas.json @@ -128,5 +128,43 @@ "valid": false } ] + }, + { + "description": "dependent subschema incompatible with root", + "schema": { + "properties": { + "foo": {} + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": {} + }, + "additionalProperties": false + } + } + }, + "tests": [ + { + "description": "matches root", + "data": {"foo": 1}, + "valid": false + }, + { + "description": "matches dependency", + "data": {"bar": 1}, + "valid": true + }, + { + "description": "matches both", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "no dependency", + "data": {"baz": 1}, + "valid": true + } + ] } ] diff --git a/tests/draft-next/format.json b/tests/draft-next/format.json index 43a8bd6..ec6c7f1 100644 --- a/tests/draft-next/format.json +++ b/tests/draft-next/format.json @@ -35,6 +35,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid email string is only an annotation by default", + "data": "2962", + "valid": true } ] }, @@ -74,6 +79,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid idn-email string is only an annotation by default", + "data": "2962", + "valid": true } ] }, @@ -113,6 +123,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid regex string is only an annotation by default", + "data": "^(abc]", + "valid": true } ] }, @@ -152,6 +167,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid ipv4 string is only an annotation by default", + "data": "127.0.0.0.1", + "valid": true } ] }, @@ -191,6 +211,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid ipv6 string is only an annotation by default", + "data": "12345::", + "valid": true } ] }, @@ -230,6 +255,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid idn-hostname string is only an annotation by default", + "data": "〮실례.테스트", + "valid": true } ] }, @@ -269,6 +299,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid hostname string is only an annotation by default", + "data": "-a-host-name-that-starts-with--", + "valid": true } ] }, @@ -308,6 +343,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid date string is only an annotation by default", + "data": "06/19/1963", + "valid": true } ] }, @@ -347,6 +387,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid date-time string is only an annotation by default", + "data": "1990-02-31T15:59:60.123-08:00", + "valid": true } ] }, @@ -386,6 +431,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid time string is only an annotation by default", + "data": "08:30:06 PST", + "valid": true } ] }, @@ -425,6 +475,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid json-pointer string is only an annotation by default", + "data": "/foo/bar~", + "valid": true } ] }, @@ -464,6 +519,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid relative-json-pointer string is only an annotation by default", + "data": "/foo/bar", + "valid": true } ] }, @@ -503,6 +563,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid iri string is only an annotation by default", + "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "valid": true } ] }, @@ -542,6 +607,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid iri-reference string is only an annotation by default", + "data": "\\\\WINDOWS\\filëßåré", + "valid": true } ] }, @@ -581,6 +651,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uri string is only an annotation by default", + "data": "//foo.bar/?baz=qux#quux", + "valid": true } ] }, @@ -620,6 +695,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uri-reference string is only an annotation by default", + "data": "\\\\WINDOWS\\fileshare", + "valid": true } ] }, @@ -659,6 +739,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uri-template string is only an annotation by default", + "data": "http://example.com/dictionary/{term:1}/{term", + "valid": true } ] }, @@ -698,6 +783,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uuid string is only an annotation by default", + "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638", + "valid": true } ] }, @@ -737,6 +827,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid duration string is only an annotation by default", + "data": "PT1D", + "valid": true } ] } diff --git a/tests/draft-next/ref.json b/tests/draft-next/ref.json index 6457e8a..1d5f256 100644 --- a/tests/draft-next/ref.json +++ b/tests/draft-next/ref.json @@ -601,16 +601,16 @@ "schema": { "$schema": "https://json-schema.org/draft/next/schema", "$comment": "$id must be evaluated before $ref to get the proper $ref destination", - "$id": "/draft/next/ref-and-id1/base.json", + "$id": "https://example.com/draft/next/ref-and-id1/base.json", "$ref": "int.json", "$defs": { "bigint": { - "$comment": "canonical uri: /ref-and-id1/int.json", + "$comment": "canonical uri: https://example.com/ref-and-id1/int.json", "$id": "int.json", "maximum": 10 }, "smallint": { - "$comment": "canonical uri: /ref-and-id1-int.json", + "$comment": "canonical uri: https://example.com/ref-and-id1-int.json", "$id": "/draft/next/ref-and-id1-int.json", "maximum": 2 } @@ -634,16 +634,16 @@ "schema": { "$schema": "https://json-schema.org/draft/next/schema", "$comment": "$id must be evaluated before $ref to get the proper $ref destination", - "$id": "/draft/next/ref-and-id2/base.json", + "$id": "https://example.com/draft/next/ref-and-id2/base.json", "$ref": "#bigint", "$defs": { "bigint": { - "$comment": "canonical uri: /ref-and-id2/base.json#/$defs/bigint; another valid uri for this location: /ref-and-id2/base.json#bigint", + "$comment": "canonical uri: https://example.com/ref-and-id2/base.json#/$defs/bigint; another valid uri for this location: https://example.com/ref-and-id2/base.json#bigint", "$anchor": "bigint", "maximum": 10 }, "smallint": { - "$comment": "canonical uri: /ref-and-id2#/$defs/smallint; another valid uri for this location: /ref-and-id2/#bigint", + "$comment": "canonical uri: https://example.com/ref-and-id2#/$defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint", "$id": "/draft/next/ref-and-id2/", "$anchor": "bigint", "maximum": 2 @@ -951,32 +951,109 @@ ] }, { - "description": "ref with absolute-path-reference", - "schema": { - "$id": "http://example.com/ref/absref.json", - "$defs": { - "a": { - "$id": "http://example.com/ref/absref/foobar.json", - "type": "number" - }, - "b": { - "$id": "http://example.com/absref/foobar.json", - "type": "string" - } - }, - "$ref": "/absref/foobar.json" - }, - "tests": [ - { - "description": "a string is valid", - "data": "foo", - "valid": true - }, - { - "description": "an integer is invalid", - "data": 12, - "valid": false - } - ] - } + "description": "ref with absolute-path-reference", + "schema": { + "$id": "http://example.com/ref/absref.json", + "$defs": { + "a": { + "$id": "http://example.com/ref/absref/foobar.json", + "type": "number" + }, + "b": { + "$id": "http://example.com/absref/foobar.json", + "type": "string" + } + }, + "$ref": "/absref/foobar.json" + }, + "tests": [ + { + "description": "a string is valid", + "data": "foo", + "valid": true + }, + { + "description": "an integer is invalid", + "data": 12, + "valid": false + } + ] + }, + { + "description": "$id with file URI still resolves pointers - *nix", + "schema": { + "$id": "file:///folder/file.json", + "$defs": { + "foo": { + "type": "number" + } + }, + "$ref": "#/$defs/foo" + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "$id with file URI still resolves pointers - windows", + "schema": { + "$id": "file:///c:/folder/file.json", + "$defs": { + "foo": { + "type": "number" + } + }, + "$ref": "#/$defs/foo" + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "empty tokens in $ref json-pointer", + "schema": { + "$defs": { + "": { + "$defs": { + "": { "type": "number" } + } + } + }, + "allOf": [ + { + "$ref": "#/$defs//$defs/" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + } ] diff --git a/tests/draft-next/unevaluatedItems.json b/tests/draft-next/unevaluatedItems.json index ce5d043..7379afb 100644 --- a/tests/draft-next/unevaluatedItems.json +++ b/tests/draft-next/unevaluatedItems.json @@ -692,5 +692,28 @@ "valid": true } ] + }, + { + "description": "unevaluatedItems can see annotations from if without then and else", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "if": { + "prefixItems": [{"const": "a"}] + }, + "unevaluatedItems": false + }, + "tests": [ + { + "description": "valid in case if is evaluated", + "data": [ "a" ], + "valid": true + }, + { + "description": "invalid in case if is evaluated", + "data": [ "b" ], + "valid": false + } + + ] } ] diff --git a/tests/draft-next/unevaluatedProperties.json b/tests/draft-next/unevaluatedProperties.json index f3d4012..69fe8a0 100644 --- a/tests/draft-next/unevaluatedProperties.json +++ b/tests/draft-next/unevaluatedProperties.json @@ -1232,7 +1232,7 @@ ] }, { - "description": "dynamic evalation inside nested refs", + "description": "dynamic evaluation inside nested refs", "schema": { "$schema": "https://json-schema.org/draft/next/schema", "$defs": { @@ -1482,7 +1482,7 @@ }, "propertyDependencies": { "foo": { - "foo1": { + "foo1": { "properties": { "bar": true } @@ -1538,5 +1538,35 @@ "valid": false } ] + }, + { + "description": "unevaluatedProperties can see annotations from if without then and else", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "if": { + "patternProperties": { + "foo": { + "type": "string" + } + } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "valid in case if is evaluated", + "data": { + "foo": "a" + }, + "valid": true + }, + { + "description": "invalid in case if is evaluated", + "data": { + "bar": "a" + }, + "valid": false + } + ] } ] diff --git a/tests/draft-next/uniqueItems.json b/tests/draft-next/uniqueItems.json index 610b257..b16dd50 100644 --- a/tests/draft-next/uniqueItems.json +++ b/tests/draft-next/uniqueItems.json @@ -57,6 +57,11 @@ "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}}}, diff --git a/tests/draft2019-09/dependentSchemas.json b/tests/draft2019-09/dependentSchemas.json index b397583..3577efd 100644 --- a/tests/draft2019-09/dependentSchemas.json +++ b/tests/draft2019-09/dependentSchemas.json @@ -128,5 +128,43 @@ "valid": false } ] + }, + { + "description": "dependent subschema incompatible with root", + "schema": { + "properties": { + "foo": {} + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": {} + }, + "additionalProperties": false + } + } + }, + "tests": [ + { + "description": "matches root", + "data": {"foo": 1}, + "valid": false + }, + { + "description": "matches dependency", + "data": {"bar": 1}, + "valid": true + }, + { + "description": "matches both", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "no dependency", + "data": {"baz": 1}, + "valid": true + } + ] } ] diff --git a/tests/draft2019-09/recursiveRef.json b/tests/draft2019-09/recursiveRef.json index 1e713ff..22b47e7 100644 --- a/tests/draft2019-09/recursiveRef.json +++ b/tests/draft2019-09/recursiveRef.json @@ -318,7 +318,7 @@ "description": "multiple dynamic paths to the $recursiveRef keyword", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "recursiveRef8_main.json", + "$id": "https://example.com/recursiveRef8_main.json", "$defs": { "inner": { "$id": "recursiveRef8_inner.json", @@ -365,7 +365,7 @@ "description": "dynamic $recursiveRef destination (not predictable at schema compile time)", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "main.json", + "$id": "https://example.com/main.json", "$defs": { "inner": { "$id": "inner.json", diff --git a/tests/draft2019-09/ref.json b/tests/draft2019-09/ref.json index d420bd9..7d85041 100644 --- a/tests/draft2019-09/ref.json +++ b/tests/draft2019-09/ref.json @@ -601,16 +601,16 @@ "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", "$comment": "$id must be evaluated before $ref to get the proper $ref destination", - "$id": "/draft2019-09/ref-and-id1/base.json", + "$id": "https://example.com/draft2019-09/ref-and-id1/base.json", "$ref": "int.json", "$defs": { "bigint": { - "$comment": "canonical uri: /draft2019-09/ref-and-id1/int.json", + "$comment": "canonical uri: https://example.com/draft2019-09/ref-and-id1/int.json", "$id": "int.json", "maximum": 10 }, "smallint": { - "$comment": "canonical uri: /draft2019-09/ref-and-id1-int.json", + "$comment": "canonical uri: https://example.com/draft2019-09/ref-and-id1-int.json", "$id": "/draft2019-09/ref-and-id1-int.json", "maximum": 2 } @@ -634,16 +634,16 @@ "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", "$comment": "$id must be evaluated before $ref to get the proper $ref destination", - "$id": "/draft2019-09/ref-and-id2/base.json", + "$id": "https://example.com/draft2019-09/ref-and-id2/base.json", "$ref": "#bigint", "$defs": { "bigint": { - "$comment": "canonical uri: /draft2019-09/ref-and-id2/base.json#/$defs/bigint; another valid uri for this location: /ref-and-id2/base.json#bigint", + "$comment": "canonical uri: https://example.com/draft2019-09/ref-and-id2/base.json#/$defs/bigint; another valid uri for this location: https://example.com/ref-and-id2/base.json#bigint", "$anchor": "bigint", "maximum": 10 }, "smallint": { - "$comment": "canonical uri: /draft2019-09/ref-and-id2#/$defs/smallint; another valid uri for this location: /ref-and-id2/#bigint", + "$comment": "canonical uri: https://example.com/draft2019-09/ref-and-id2#/$defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint", "$id": "/draft2019-09/ref-and-id2/", "$anchor": "bigint", "maximum": 2 @@ -978,5 +978,82 @@ "valid": false } ] + }, + { + "description": "$id with file URI still resolves pointers - *nix", + "schema": { + "$id": "file:///folder/file.json", + "$defs": { + "foo": { + "type": "number" + } + }, + "$ref": "#/$defs/foo" + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "$id with file URI still resolves pointers - windows", + "schema": { + "$id": "file:///c:/folder/file.json", + "$defs": { + "foo": { + "type": "number" + } + }, + "$ref": "#/$defs/foo" + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "empty tokens in $ref json-pointer", + "schema": { + "$defs": { + "": { + "$defs": { + "": { "type": "number" } + } + } + }, + "allOf": [ + { + "$ref": "#/$defs//$defs/" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft2019-09/unevaluatedItems.json b/tests/draft2019-09/unevaluatedItems.json index a0b1f33..53565a0 100644 --- a/tests/draft2019-09/unevaluatedItems.json +++ b/tests/draft2019-09/unevaluatedItems.json @@ -600,5 +600,28 @@ "valid": true } ] + }, + { + "description": "unevaluatedItems can see annotations from if without then and else", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "if": { + "items": [{"const": "a"}] + }, + "unevaluatedItems": false + }, + "tests": [ + { + "description": "valid in case if is evaluated", + "data": [ "a" ], + "valid": true + }, + { + "description": "invalid in case if is evaluated", + "data": [ "b" ], + "valid": false + } + + ] } ] diff --git a/tests/draft2019-09/unevaluatedProperties.json b/tests/draft2019-09/unevaluatedProperties.json index fdb4ac9..a6cce8b 100644 --- a/tests/draft2019-09/unevaluatedProperties.json +++ b/tests/draft2019-09/unevaluatedProperties.json @@ -1441,5 +1441,35 @@ "valid": false } ] + }, + { + "description": "unevaluatedProperties can see annotations from if without then and else", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "if": { + "patternProperties": { + "foo": { + "type": "string" + } + } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "valid in case if is evaluated", + "data": { + "foo": "a" + }, + "valid": true + }, + { + "description": "invalid in case if is evaluated", + "data": { + "bar": "a" + }, + "valid": false + } + ] } ] diff --git a/tests/draft2019-09/uniqueItems.json b/tests/draft2019-09/uniqueItems.json index 6da878b..314b4b9 100644 --- a/tests/draft2019-09/uniqueItems.json +++ b/tests/draft2019-09/uniqueItems.json @@ -57,6 +57,11 @@ "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}}}, diff --git a/tests/draft2020-12/dependentSchemas.json b/tests/draft2020-12/dependentSchemas.json index bf7aa53..66ac0eb 100644 --- a/tests/draft2020-12/dependentSchemas.json +++ b/tests/draft2020-12/dependentSchemas.json @@ -128,5 +128,43 @@ "valid": false } ] + }, + { + "description": "dependent subschema incompatible with root", + "schema": { + "properties": { + "foo": {} + }, + "dependentSchemas": { + "foo": { + "properties": { + "bar": {} + }, + "additionalProperties": false + } + } + }, + "tests": [ + { + "description": "matches root", + "data": {"foo": 1}, + "valid": false + }, + { + "description": "matches dependency", + "data": {"bar": 1}, + "valid": true + }, + { + "description": "matches both", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "no dependency", + "data": {"baz": 1}, + "valid": true + } + ] } ] diff --git a/tests/draft2020-12/format.json b/tests/draft2020-12/format.json index 6b7904e..01adcbd 100644 --- a/tests/draft2020-12/format.json +++ b/tests/draft2020-12/format.json @@ -35,6 +35,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid email string is only an annotation by default", + "data": "2962", + "valid": true } ] }, @@ -74,6 +79,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid idn-email string is only an annotation by default", + "data": "2962", + "valid": true } ] }, @@ -113,6 +123,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid regex string is only an annotation by default", + "data": "^(abc]", + "valid": true } ] }, @@ -152,6 +167,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid ipv4 string is only an annotation by default", + "data": "127.0.0.0.1", + "valid": true } ] }, @@ -191,6 +211,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid ipv6 string is only an annotation by default", + "data": "12345::", + "valid": true } ] }, @@ -230,6 +255,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid idn-hostname string is only an annotation by default", + "data": "〮실례.테스트", + "valid": true } ] }, @@ -269,6 +299,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid hostname string is only an annotation by default", + "data": "-a-host-name-that-starts-with--", + "valid": true } ] }, @@ -308,6 +343,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid date string is only an annotation by default", + "data": "06/19/1963", + "valid": true } ] }, @@ -347,6 +387,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid date-time string is only an annotation by default", + "data": "1990-02-31T15:59:60.123-08:00", + "valid": true } ] }, @@ -386,6 +431,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid time string is only an annotation by default", + "data": "08:30:06 PST", + "valid": true } ] }, @@ -425,6 +475,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid json-pointer string is only an annotation by default", + "data": "/foo/bar~", + "valid": true } ] }, @@ -464,6 +519,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid relative-json-pointer string is only an annotation by default", + "data": "/foo/bar", + "valid": true } ] }, @@ -503,6 +563,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid iri string is only an annotation by default", + "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "valid": true } ] }, @@ -542,6 +607,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid iri-reference string is only an annotation by default", + "data": "\\\\WINDOWS\\filëßåré", + "valid": true } ] }, @@ -581,6 +651,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uri string is only an annotation by default", + "data": "//foo.bar/?baz=qux#quux", + "valid": true } ] }, @@ -620,6 +695,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uri-reference string is only an annotation by default", + "data": "\\\\WINDOWS\\fileshare", + "valid": true } ] }, @@ -659,6 +739,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uri-template string is only an annotation by default", + "data": "http://example.com/dictionary/{term:1}/{term", + "valid": true } ] }, @@ -698,6 +783,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid uuid string is only an annotation by default", + "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638", + "valid": true } ] }, @@ -737,6 +827,11 @@ "description": "all string formats ignore nulls", "data": null, "valid": true + }, + { + "description": "invalid duration string is only an annotation by default", + "data": "PT1D", + "valid": true } ] } diff --git a/tests/draft2020-12/ref.json b/tests/draft2020-12/ref.json index 72c593a..5f6be8c 100644 --- a/tests/draft2020-12/ref.json +++ b/tests/draft2020-12/ref.json @@ -601,16 +601,16 @@ "schema": { "$comment": "$id must be evaluated before $ref to get the proper $ref destination", "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "/draft2020-12/ref-and-id1/base.json", + "$id": "https://example.com/draft2020-12/ref-and-id1/base.json", "$ref": "int.json", "$defs": { "bigint": { - "$comment": "canonical uri: /ref-and-id1/int.json", + "$comment": "canonical uri: https://example.com/ref-and-id1/int.json", "$id": "int.json", "maximum": 10 }, "smallint": { - "$comment": "canonical uri: /ref-and-id1-int.json", + "$comment": "canonical uri: https://example.com/ref-and-id1-int.json", "$id": "/draft2020-12/ref-and-id1-int.json", "maximum": 2 } @@ -634,7 +634,7 @@ "schema": { "$comment": "$id must be evaluated before $ref to get the proper $ref destination", "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "/draft2020-12/ref-and-id2/base.json", + "$id": "https://example.com/draft2020-12/ref-and-id2/base.json", "$ref": "#bigint", "$defs": { "bigint": { @@ -643,8 +643,8 @@ "maximum": 10 }, "smallint": { - "$comment": "canonical uri: /ref-and-id2#/$defs/smallint; another valid uri for this location: /ref-and-id2/#bigint", - "$id": "/draft2020-12/ref-and-id2/", + "$comment": "canonical uri: https://example.com/ref-and-id2#/$defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint", + "$id": "https://example.com/draft2020-12/ref-and-id2/", "$anchor": "bigint", "maximum": 2 } @@ -978,5 +978,82 @@ "valid": false } ] + }, + { + "description": "$id with file URI still resolves pointers - *nix", + "schema": { + "$id": "file:///folder/file.json", + "$defs": { + "foo": { + "type": "number" + } + }, + "$ref": "#/$defs/foo" + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "$id with file URI still resolves pointers - windows", + "schema": { + "$id": "file:///c:/folder/file.json", + "$defs": { + "foo": { + "type": "number" + } + }, + "$ref": "#/$defs/foo" + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "empty tokens in $ref json-pointer", + "schema": { + "$defs": { + "": { + "$defs": { + "": { "type": "number" } + } + } + }, + "allOf": [ + { + "$ref": "#/$defs//$defs/" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/unevaluatedItems.json b/tests/draft2020-12/unevaluatedItems.json index 2b816af..2615c4c 100644 --- a/tests/draft2020-12/unevaluatedItems.json +++ b/tests/draft2020-12/unevaluatedItems.json @@ -692,5 +692,28 @@ "valid": true } ] + }, + { + "description": "unevaluatedItems can see annotations from if without then and else", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "prefixItems": [{"const": "a"}] + }, + "unevaluatedItems": false + }, + "tests": [ + { + "description": "valid in case if is evaluated", + "data": [ "a" ], + "valid": true + }, + { + "description": "invalid in case if is evaluated", + "data": [ "b" ], + "valid": false + } + + ] } ] diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index 00cb36c..f7fb420 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -1441,5 +1441,35 @@ "valid": false } ] + }, + { + "description": "unevaluatedProperties can see annotations from if without then and else", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "if": { + "patternProperties": { + "foo": { + "type": "string" + } + } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "valid in case if is evaluated", + "data": { + "foo": "a" + }, + "valid": true + }, + { + "description": "invalid in case if is evaluated", + "data": { + "bar": "a" + }, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/uniqueItems.json b/tests/draft2020-12/uniqueItems.json index 707235c..4ea3bf9 100644 --- a/tests/draft2020-12/uniqueItems.json +++ b/tests/draft2020-12/uniqueItems.json @@ -57,6 +57,11 @@ "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}}}, diff --git a/tests/draft4/dependencies.json b/tests/draft4/dependencies.json index 51eeddf..9045ddc 100644 --- a/tests/draft4/dependencies.json +++ b/tests/draft4/dependencies.json @@ -190,5 +190,43 @@ "valid": false } ] + }, + { + "description": "dependent subschema incompatible with root", + "schema": { + "properties": { + "foo": {} + }, + "dependencies": { + "foo": { + "properties": { + "bar": {} + }, + "additionalProperties": false + } + } + }, + "tests": [ + { + "description": "matches root", + "data": {"foo": 1}, + "valid": false + }, + { + "description": "matches dependency", + "data": {"bar": 1}, + "valid": true + }, + { + "description": "matches both", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "no dependency", + "data": {"baz": 1}, + "valid": true + } + ] } ] diff --git a/tests/draft4/ref.json b/tests/draft4/ref.json index b714fb0..b53bd2a 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -503,5 +503,90 @@ "valid": false } ] + }, + { + "description": "id with file URI still resolves pointers - *nix", + "schema": { + "id": "file:///folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "$ref": "#/definitions/foo" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "id with file URI still resolves pointers - windows", + "schema": { + "id": "file:///c:/folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "$ref": "#/definitions/foo" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "empty tokens in $ref json-pointer", + "schema": { + "definitions": { + "": { + "definitions": { + "": { "type": "number" } + } + } + }, + "allOf": [ + { + "$ref": "#/definitions//definitions/" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft4/uniqueItems.json b/tests/draft4/uniqueItems.json index 2ccf666..d2730c6 100644 --- a/tests/draft4/uniqueItems.json +++ b/tests/draft4/uniqueItems.json @@ -54,6 +54,11 @@ "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}}}, diff --git a/tests/draft6/dependencies.json b/tests/draft6/dependencies.json index a5e5428..c0bd809 100644 --- a/tests/draft6/dependencies.json +++ b/tests/draft6/dependencies.json @@ -244,5 +244,43 @@ "valid": false } ] + }, + { + "description": "dependent subschema incompatible with root", + "schema": { + "properties": { + "foo": {} + }, + "dependencies": { + "foo": { + "properties": { + "bar": {} + }, + "additionalProperties": false + } + } + }, + "tests": [ + { + "description": "matches root", + "data": {"foo": 1}, + "valid": false + }, + { + "description": "matches dependency", + "data": {"bar": 1}, + "valid": true + }, + { + "description": "matches both", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "no dependency", + "data": {"baz": 1}, + "valid": true + } + ] } ] diff --git a/tests/draft6/ref.json b/tests/draft6/ref.json index 8a36593..8a8908a 100644 --- a/tests/draft6/ref.json +++ b/tests/draft6/ref.json @@ -813,5 +813,90 @@ "valid": false } ] + }, + { + "description": "$id with file URI still resolves pointers - *nix", + "schema": { + "$id": "file:///folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "$ref": "#/definitions/foo" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "$id with file URI still resolves pointers - windows", + "schema": { + "$id": "file:///c:/folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "$ref": "#/definitions/foo" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "empty tokens in $ref json-pointer", + "schema": { + "definitions": { + "": { + "definitions": { + "": { "type": "number" } + } + } + }, + "allOf": [ + { + "$ref": "#/definitions//definitions/" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft6/uniqueItems.json b/tests/draft6/uniqueItems.json index 2ccf666..d2730c6 100644 --- a/tests/draft6/uniqueItems.json +++ b/tests/draft6/uniqueItems.json @@ -54,6 +54,11 @@ "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}}}, diff --git a/tests/draft7/dependencies.json b/tests/draft7/dependencies.json index a5e5428..c0bd809 100644 --- a/tests/draft7/dependencies.json +++ b/tests/draft7/dependencies.json @@ -244,5 +244,43 @@ "valid": false } ] + }, + { + "description": "dependent subschema incompatible with root", + "schema": { + "properties": { + "foo": {} + }, + "dependencies": { + "foo": { + "properties": { + "bar": {} + }, + "additionalProperties": false + } + } + }, + "tests": [ + { + "description": "matches root", + "data": {"foo": 1}, + "valid": false + }, + { + "description": "matches dependency", + "data": {"bar": 1}, + "valid": true + }, + { + "description": "matches both", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "no dependency", + "data": {"baz": 1}, + "valid": true + } + ] } ] diff --git a/tests/draft7/ref.json b/tests/draft7/ref.json index 2bee83e..8263172 100644 --- a/tests/draft7/ref.json +++ b/tests/draft7/ref.json @@ -927,5 +927,90 @@ "valid": false } ] + }, + { + "description": "$id with file URI still resolves pointers - *nix", + "schema": { + "$id": "file:///folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "$ref": "#/definitions/foo" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "$id with file URI still resolves pointers - windows", + "schema": { + "$id": "file:///c:/folder/file.json", + "definitions": { + "foo": { + "type": "number" + } + }, + "allOf": [ + { + "$ref": "#/definitions/foo" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "empty tokens in $ref json-pointer", + "schema": { + "definitions": { + "": { + "definitions": { + "": { "type": "number" } + } + } + }, + "allOf": [ + { + "$ref": "#/definitions//definitions/" + } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "non-number is invalid", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft7/uniqueItems.json b/tests/draft7/uniqueItems.json index 2ccf666..d2730c6 100644 --- a/tests/draft7/uniqueItems.json +++ b/tests/draft7/uniqueItems.json @@ -54,6 +54,11 @@ "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}}}, |