diff options
author | Julian Berman <Julian@GrayVines.com> | 2022-06-25 01:14:24 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2022-06-25 01:14:24 -0400 |
commit | 76b2e597d691e4cf5e9ebb7f3d1cff4f5da0115a (patch) | |
tree | ff112f2867dcdb21cf61afe178f810426f83206d /json/tests | |
parent | 2f3a79c61176f60c9244d07fa8afb728218270ff (diff) | |
parent | 095a009acc1938caf9596085d5581e7196021f66 (diff) | |
download | jsonschema-76b2e597d691e4cf5e9ebb7f3d1cff4f5da0115a.tar.gz |
Merge commit '095a009acc1938caf9596085d5581e7196021f66'
* commit '095a009acc1938caf9596085d5581e7196021f66':
Squashed 'json/' changes from cf78d97d0..f0f619d19
Diffstat (limited to 'json/tests')
53 files changed, 1917 insertions, 9 deletions
diff --git a/json/tests/draft-next/anchor.json b/json/tests/draft-next/anchor.json index 416c224..4e8987e 100644 --- a/json/tests/draft-next/anchor.json +++ b/json/tests/draft-next/anchor.json @@ -169,5 +169,36 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $anchor property", + "schema": { + "$defs": { + "const_not_anchor": { + "const": { + "$anchor": "not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/id.json b/json/tests/draft-next/id.json index c5eab10..db7afaf 100644 --- a/json/tests/draft-next/id.json +++ b/json/tests/draft-next/id.json @@ -254,5 +254,36 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/maxContains.json b/json/tests/draft-next/maxContains.json index e95bb9f..7ed1dcf 100644 --- a/json/tests/draft-next/maxContains.json +++ b/json/tests/draft-next/maxContains.json @@ -87,6 +87,25 @@ ] }, { + "description": "maxContains with contains, value with a decimal", + "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": { "contains": { "const": 1 }, diff --git a/json/tests/draft-next/maxItems.json b/json/tests/draft-next/maxItems.json index 3b53a6b..f0c36ab 100644 --- a/json/tests/draft-next/maxItems.json +++ b/json/tests/draft-next/maxItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "maxItems validation with a decimal", + "schema": {"maxItems": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": [1], + "valid": true + }, + { + "description": "too long is invalid", + "data": [1, 2, 3], + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/maxLength.json b/json/tests/draft-next/maxLength.json index 811d35b..748b4da 100644 --- a/json/tests/draft-next/maxLength.json +++ b/json/tests/draft-next/maxLength.json @@ -29,5 +29,21 @@ "valid": true } ] + }, + { + "description": "maxLength validation with a decimal", + "schema": {"maxLength": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": "f", + "valid": true + }, + { + "description": "too long is invalid", + "data": "foo", + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/maxProperties.json b/json/tests/draft-next/maxProperties.json index aa7209f..acec142 100644 --- a/json/tests/draft-next/maxProperties.json +++ b/json/tests/draft-next/maxProperties.json @@ -36,6 +36,22 @@ ] }, { + "description": "maxProperties validation with a decimal", + "schema": {"maxProperties": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "too long is invalid", + "data": {"foo": 1, "bar": 2, "baz": 3}, + "valid": false + } + ] + }, + { "description": "maxProperties = 0 means the object is empty", "schema": { "maxProperties": 0 }, "tests": [ diff --git a/json/tests/draft-next/minContains.json b/json/tests/draft-next/minContains.json index 287cfca..b83d1bd 100644 --- a/json/tests/draft-next/minContains.json +++ b/json/tests/draft-next/minContains.json @@ -91,6 +91,25 @@ ] }, { + "description": "minContains=2 with contains with a decimal value", + "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": { "contains": { "const": 1 }, diff --git a/json/tests/draft-next/minItems.json b/json/tests/draft-next/minItems.json index ed51188..d3b1872 100644 --- a/json/tests/draft-next/minItems.json +++ b/json/tests/draft-next/minItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "minItems validation with a decimal", + "schema": {"minItems": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "too short is invalid", + "data": [], + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/minLength.json b/json/tests/draft-next/minLength.json index 3f09158..64db948 100644 --- a/json/tests/draft-next/minLength.json +++ b/json/tests/draft-next/minLength.json @@ -29,5 +29,21 @@ "valid": false } ] + }, + { + "description": "minLength validation with a decimal", + "schema": {"minLength": 2.0}, + "tests": [ + { + "description": "longer is valid", + "data": "foo", + "valid": true + }, + { + "description": "too short is invalid", + "data": "f", + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/minProperties.json b/json/tests/draft-next/minProperties.json index 49a0726..9f74f78 100644 --- a/json/tests/draft-next/minProperties.json +++ b/json/tests/draft-next/minProperties.json @@ -34,5 +34,21 @@ "valid": true } ] + }, + { + "description": "minProperties validation with a decimal", + "schema": {"minProperties": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "too short is invalid", + "data": {}, + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/optional/dependencies-compatibility.json b/json/tests/draft-next/optional/dependencies-compatibility.json new file mode 100644 index 0000000..6eafaf0 --- /dev/null +++ b/json/tests/draft-next/optional/dependencies-compatibility.json @@ -0,0 +1,269 @@ +[ + { + "description": "single dependency", + "schema": {"dependencies": {"bar": ["foo"]}}, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependant", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "with dependency", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "empty dependents", + "schema": {"dependencies": {"bar": []}}, + "tests": [ + { + "description": "empty object", + "data": {}, + "valid": true + }, + { + "description": "object with one property", + "data": {"bar": 2}, + "valid": true + }, + { + "description": "non-object is valid", + "data": 1, + "valid": true + } + ] + }, + { + "description": "multiple dependents required", + "schema": {"dependencies": {"quux": ["foo", "bar"]}}, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependants", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "with dependencies", + "data": {"foo": 1, "bar": 2, "quux": 3}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"foo": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing other dependency", + "data": {"bar": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing both dependencies", + "data": {"quux": 1}, + "valid": false + } + ] + }, + { + "description": "dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\nbar": ["foo\rbar"], + "foo\"bar": ["foo'bar"] + } + }, + "tests": [ + { + "description": "CRLF", + "data": { + "foo\nbar": 1, + "foo\rbar": 2 + }, + "valid": true + }, + { + "description": "quoted quotes", + "data": { + "foo'bar": 1, + "foo\"bar": 2 + }, + "valid": true + }, + { + "description": "CRLF missing dependent", + "data": { + "foo\nbar": 1, + "foo": 2 + }, + "valid": false + }, + { + "description": "quoted quotes missing dependent", + "data": { + "foo\"bar": 2 + }, + "valid": false + } + ] + }, + { + "description": "single schema dependency", + "schema": { + "dependencies": { + "bar": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"type": "integer"} + } + } + } + }, + "tests": [ + { + "description": "valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "no dependency", + "data": {"foo": "quux"}, + "valid": true + }, + { + "description": "wrong type", + "data": {"foo": "quux", "bar": 2}, + "valid": false + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": false + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "boolean subschemas", + "schema": { + "dependencies": { + "foo": true, + "bar": false + } + }, + "tests": [ + { + "description": "object with property having schema true is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "object with property having schema false is invalid", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "object with both properties is invalid", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "schema dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\tbar": {"minProperties": 4}, + "foo'bar": {"required": ["foo\"bar"]} + } + }, + "tests": [ + { + "description": "quoted tab", + "data": { + "foo\tbar": 1, + "a": 2, + "b": 3, + "c": 4 + }, + "valid": true + }, + { + "description": "quoted quote", + "data": { + "foo'bar": {"foo\"bar": 1} + }, + "valid": false + }, + { + "description": "quoted tab invalid under dependent schema", + "data": { + "foo\tbar": 1, + "a": 2 + }, + "valid": false + }, + { + "description": "quoted quote invalid under dependent schema", + "data": {"foo'bar": 1}, + "valid": false + } + ] + } +] diff --git a/json/tests/draft-next/ref.json b/json/tests/draft-next/ref.json index bc87c9e..421b5f8 100644 --- a/json/tests/draft-next/ref.json +++ b/json/tests/draft-next/ref.json @@ -577,5 +577,70 @@ "valid": false } ] + }, + { + "description": "order of evaluation: $id and $ref", + "schema": { + "$comment": "$id must be evaluated before $ref to get the proper $ref destination", + "$id": "/ref-and-id1/base.json", + "$ref": "int.json", + "$defs": { + "bigint": { + "$comment": "canonical uri: /ref-and-id1/int.json", + "$id": "int.json", + "maximum": 10 + }, + "smallint": { + "$comment": "canonical uri: /ref-and-id1-int.json", + "$id": "/ref-and-id1-int.json", + "maximum": 2 + } + } + }, + "tests": [ + { + "description": "data is valid against first definition", + "data": 5, + "valid": true + }, + { + "description": "data is invalid against first definition", + "data": 50, + "valid": false + } + ] + }, + { + "description": "order of evaluation: $id and $anchor and $ref", + "schema": { + "$comment": "$id must be evaluated before $ref to get the proper $ref destination", + "$id": "/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", + "$anchor": "bigint", + "maximum": 10 + }, + "smallint": { + "$comment": "canonical uri: /ref-and-id2#/$defs/smallint; another valid uri for this location: /ref-and-id2/#bigint", + "$id": "/ref-and-id2/", + "$anchor": "bigint", + "maximum": 2 + } + } + }, + "tests": [ + { + "description": "data is valid against first definition", + "data": 5, + "valid": true + }, + { + "description": "data is invalid against first definition", + "data": 50, + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/refRemote.json b/json/tests/draft-next/refRemote.json index f122864..0a5e484 100644 --- a/json/tests/draft-next/refRemote.json +++ b/json/tests/draft-next/refRemote.json @@ -190,7 +190,7 @@ { "description": "Location-independent identifier in remote ref", "schema": { - "$ref": "http://localhost:1234/locationIndependentIdentifier.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/locationIndependentIdentifier.json#/$defs/refToInteger" }, "tests": [ { diff --git a/json/tests/draft2019-09/anchor.json b/json/tests/draft2019-09/anchor.json index 416c224..4e8987e 100644 --- a/json/tests/draft2019-09/anchor.json +++ b/json/tests/draft2019-09/anchor.json @@ -169,5 +169,36 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $anchor property", + "schema": { + "$defs": { + "const_not_anchor": { + "const": { + "$anchor": "not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/id.json b/json/tests/draft2019-09/id.json index e225aad..0d825ea 100644 --- a/json/tests/draft2019-09/id.json +++ b/json/tests/draft2019-09/id.json @@ -1,7 +1,9 @@ [ { "description": "Invalid use of fragments in location-independent $id", - "schema": {"$ref": "https://json-schema.org/draft/2019-09/schema"}, + "schema": { + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, "tests": [ { "description": "Identifier name", @@ -252,5 +254,36 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/maxContains.json b/json/tests/draft2019-09/maxContains.json index 3c42fb3..61c967d 100644 --- a/json/tests/draft2019-09/maxContains.json +++ b/json/tests/draft2019-09/maxContains.json @@ -52,6 +52,25 @@ ] }, { + "description": "maxContains with contains, value with a decimal", + "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": { "contains": {"const": 1}, diff --git a/json/tests/draft2019-09/maxItems.json b/json/tests/draft2019-09/maxItems.json index 3b53a6b..f0c36ab 100644 --- a/json/tests/draft2019-09/maxItems.json +++ b/json/tests/draft2019-09/maxItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "maxItems validation with a decimal", + "schema": {"maxItems": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": [1], + "valid": true + }, + { + "description": "too long is invalid", + "data": [1, 2, 3], + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/maxLength.json b/json/tests/draft2019-09/maxLength.json index 811d35b..748b4da 100644 --- a/json/tests/draft2019-09/maxLength.json +++ b/json/tests/draft2019-09/maxLength.json @@ -29,5 +29,21 @@ "valid": true } ] + }, + { + "description": "maxLength validation with a decimal", + "schema": {"maxLength": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": "f", + "valid": true + }, + { + "description": "too long is invalid", + "data": "foo", + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/maxProperties.json b/json/tests/draft2019-09/maxProperties.json index aa7209f..acec142 100644 --- a/json/tests/draft2019-09/maxProperties.json +++ b/json/tests/draft2019-09/maxProperties.json @@ -36,6 +36,22 @@ ] }, { + "description": "maxProperties validation with a decimal", + "schema": {"maxProperties": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "too long is invalid", + "data": {"foo": 1, "bar": 2, "baz": 3}, + "valid": false + } + ] + }, + { "description": "maxProperties = 0 means the object is empty", "schema": { "maxProperties": 0 }, "tests": [ diff --git a/json/tests/draft2019-09/minContains.json b/json/tests/draft2019-09/minContains.json index 163247f..1d3b5a5 100644 --- a/json/tests/draft2019-09/minContains.json +++ b/json/tests/draft2019-09/minContains.json @@ -91,6 +91,25 @@ ] }, { + "description": "minContains=2 with contains with a decimal value", + "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": { "contains": {"const": 1}, diff --git a/json/tests/draft2019-09/minItems.json b/json/tests/draft2019-09/minItems.json index ed51188..d3b1872 100644 --- a/json/tests/draft2019-09/minItems.json +++ b/json/tests/draft2019-09/minItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "minItems validation with a decimal", + "schema": {"minItems": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "too short is invalid", + "data": [], + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/minLength.json b/json/tests/draft2019-09/minLength.json index 3f09158..64db948 100644 --- a/json/tests/draft2019-09/minLength.json +++ b/json/tests/draft2019-09/minLength.json @@ -29,5 +29,21 @@ "valid": false } ] + }, + { + "description": "minLength validation with a decimal", + "schema": {"minLength": 2.0}, + "tests": [ + { + "description": "longer is valid", + "data": "foo", + "valid": true + }, + { + "description": "too short is invalid", + "data": "f", + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/minProperties.json b/json/tests/draft2019-09/minProperties.json index 49a0726..9f74f78 100644 --- a/json/tests/draft2019-09/minProperties.json +++ b/json/tests/draft2019-09/minProperties.json @@ -34,5 +34,21 @@ "valid": true } ] + }, + { + "description": "minProperties validation with a decimal", + "schema": {"minProperties": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "too short is invalid", + "data": {}, + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/optional/dependencies-compatibility.json b/json/tests/draft2019-09/optional/dependencies-compatibility.json new file mode 100644 index 0000000..6eafaf0 --- /dev/null +++ b/json/tests/draft2019-09/optional/dependencies-compatibility.json @@ -0,0 +1,269 @@ +[ + { + "description": "single dependency", + "schema": {"dependencies": {"bar": ["foo"]}}, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependant", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "with dependency", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "empty dependents", + "schema": {"dependencies": {"bar": []}}, + "tests": [ + { + "description": "empty object", + "data": {}, + "valid": true + }, + { + "description": "object with one property", + "data": {"bar": 2}, + "valid": true + }, + { + "description": "non-object is valid", + "data": 1, + "valid": true + } + ] + }, + { + "description": "multiple dependents required", + "schema": {"dependencies": {"quux": ["foo", "bar"]}}, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependants", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "with dependencies", + "data": {"foo": 1, "bar": 2, "quux": 3}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"foo": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing other dependency", + "data": {"bar": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing both dependencies", + "data": {"quux": 1}, + "valid": false + } + ] + }, + { + "description": "dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\nbar": ["foo\rbar"], + "foo\"bar": ["foo'bar"] + } + }, + "tests": [ + { + "description": "CRLF", + "data": { + "foo\nbar": 1, + "foo\rbar": 2 + }, + "valid": true + }, + { + "description": "quoted quotes", + "data": { + "foo'bar": 1, + "foo\"bar": 2 + }, + "valid": true + }, + { + "description": "CRLF missing dependent", + "data": { + "foo\nbar": 1, + "foo": 2 + }, + "valid": false + }, + { + "description": "quoted quotes missing dependent", + "data": { + "foo\"bar": 2 + }, + "valid": false + } + ] + }, + { + "description": "single schema dependency", + "schema": { + "dependencies": { + "bar": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"type": "integer"} + } + } + } + }, + "tests": [ + { + "description": "valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "no dependency", + "data": {"foo": "quux"}, + "valid": true + }, + { + "description": "wrong type", + "data": {"foo": "quux", "bar": 2}, + "valid": false + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": false + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "boolean subschemas", + "schema": { + "dependencies": { + "foo": true, + "bar": false + } + }, + "tests": [ + { + "description": "object with property having schema true is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "object with property having schema false is invalid", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "object with both properties is invalid", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "schema dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\tbar": {"minProperties": 4}, + "foo'bar": {"required": ["foo\"bar"]} + } + }, + "tests": [ + { + "description": "quoted tab", + "data": { + "foo\tbar": 1, + "a": 2, + "b": 3, + "c": 4 + }, + "valid": true + }, + { + "description": "quoted quote", + "data": { + "foo'bar": {"foo\"bar": 1} + }, + "valid": false + }, + { + "description": "quoted tab invalid under dependent schema", + "data": { + "foo\tbar": 1, + "a": 2 + }, + "valid": false + }, + { + "description": "quoted quote invalid under dependent schema", + "data": {"foo'bar": 1}, + "valid": false + } + ] + } +] diff --git a/json/tests/draft2019-09/ref.json b/json/tests/draft2019-09/ref.json index fd8a3b2..55a447c 100644 --- a/json/tests/draft2019-09/ref.json +++ b/json/tests/draft2019-09/ref.json @@ -177,7 +177,9 @@ }, { "description": "remote ref, containing refs itself", - "schema": {"$ref": "https://json-schema.org/draft/2019-09/schema"}, + "schema": { + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, "tests": [ { "description": "remote ref valid", @@ -298,7 +300,7 @@ "tests": [ { "description": "valid tree", - "data": { + "data": { "meta": "root", "nodes": [ { @@ -327,7 +329,7 @@ }, { "description": "invalid tree", - "data": { + "data": { "meta": "root", "nodes": [ { @@ -575,5 +577,70 @@ "valid": false } ] + }, + { + "description": "order of evaluation: $id and $ref", + "schema": { + "$comment": "$id must be evaluated before $ref to get the proper $ref destination", + "$id": "/ref-and-id1/base.json", + "$ref": "int.json", + "$defs": { + "bigint": { + "$comment": "canonical uri: /ref-and-id1/int.json", + "$id": "int.json", + "maximum": 10 + }, + "smallint": { + "$comment": "canonical uri: /ref-and-id1-int.json", + "$id": "/ref-and-id1-int.json", + "maximum": 2 + } + } + }, + "tests": [ + { + "description": "data is valid against first definition", + "data": 5, + "valid": true + }, + { + "description": "data is invalid against first definition", + "data": 50, + "valid": false + } + ] + }, + { + "description": "order of evaluation: $id and $anchor and $ref", + "schema": { + "$comment": "$id must be evaluated before $ref to get the proper $ref destination", + "$id": "/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", + "$anchor": "bigint", + "maximum": 10 + }, + "smallint": { + "$comment": "canonical uri: /ref-and-id2#/$defs/smallint; another valid uri for this location: /ref-and-id2/#bigint", + "$id": "/ref-and-id2/", + "$anchor": "bigint", + "maximum": 2 + } + } + }, + "tests": [ + { + "description": "data is valid against first definition", + "data": 5, + "valid": true + }, + { + "description": "data is invalid against first definition", + "data": 50, + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/refRemote.json b/json/tests/draft2019-09/refRemote.json index f122864..0a5e484 100644 --- a/json/tests/draft2019-09/refRemote.json +++ b/json/tests/draft2019-09/refRemote.json @@ -190,7 +190,7 @@ { "description": "Location-independent identifier in remote ref", "schema": { - "$ref": "http://localhost:1234/locationIndependentIdentifier.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/locationIndependentIdentifier.json#/$defs/refToInteger" }, "tests": [ { diff --git a/json/tests/draft2020-12/anchor.json b/json/tests/draft2020-12/anchor.json index 416c224..4e8987e 100644 --- a/json/tests/draft2020-12/anchor.json +++ b/json/tests/draft2020-12/anchor.json @@ -169,5 +169,36 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $anchor property", + "schema": { + "$defs": { + "const_not_anchor": { + "const": { + "$anchor": "not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/id.json b/json/tests/draft2020-12/id.json index 14a0e9c..37fb429 100644 --- a/json/tests/draft2020-12/id.json +++ b/json/tests/draft2020-12/id.json @@ -254,5 +254,36 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/maxContains.json b/json/tests/draft2020-12/maxContains.json index 3c42fb3..61c967d 100644 --- a/json/tests/draft2020-12/maxContains.json +++ b/json/tests/draft2020-12/maxContains.json @@ -52,6 +52,25 @@ ] }, { + "description": "maxContains with contains, value with a decimal", + "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": { "contains": {"const": 1}, diff --git a/json/tests/draft2020-12/maxItems.json b/json/tests/draft2020-12/maxItems.json index 3b53a6b..f0c36ab 100644 --- a/json/tests/draft2020-12/maxItems.json +++ b/json/tests/draft2020-12/maxItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "maxItems validation with a decimal", + "schema": {"maxItems": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": [1], + "valid": true + }, + { + "description": "too long is invalid", + "data": [1, 2, 3], + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/maxLength.json b/json/tests/draft2020-12/maxLength.json index 811d35b..748b4da 100644 --- a/json/tests/draft2020-12/maxLength.json +++ b/json/tests/draft2020-12/maxLength.json @@ -29,5 +29,21 @@ "valid": true } ] + }, + { + "description": "maxLength validation with a decimal", + "schema": {"maxLength": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": "f", + "valid": true + }, + { + "description": "too long is invalid", + "data": "foo", + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/maxProperties.json b/json/tests/draft2020-12/maxProperties.json index aa7209f..acec142 100644 --- a/json/tests/draft2020-12/maxProperties.json +++ b/json/tests/draft2020-12/maxProperties.json @@ -36,6 +36,22 @@ ] }, { + "description": "maxProperties validation with a decimal", + "schema": {"maxProperties": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "too long is invalid", + "data": {"foo": 1, "bar": 2, "baz": 3}, + "valid": false + } + ] + }, + { "description": "maxProperties = 0 means the object is empty", "schema": { "maxProperties": 0 }, "tests": [ diff --git a/json/tests/draft2020-12/minContains.json b/json/tests/draft2020-12/minContains.json index baf5b1e..851e262 100644 --- a/json/tests/draft2020-12/minContains.json +++ b/json/tests/draft2020-12/minContains.json @@ -91,6 +91,25 @@ ] }, { + "description": "minContains=2 with contains with a decimal value", + "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": { "contains": {"const": 1}, diff --git a/json/tests/draft2020-12/minItems.json b/json/tests/draft2020-12/minItems.json index ed51188..d3b1872 100644 --- a/json/tests/draft2020-12/minItems.json +++ b/json/tests/draft2020-12/minItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "minItems validation with a decimal", + "schema": {"minItems": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "too short is invalid", + "data": [], + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/minLength.json b/json/tests/draft2020-12/minLength.json index 3f09158..64db948 100644 --- a/json/tests/draft2020-12/minLength.json +++ b/json/tests/draft2020-12/minLength.json @@ -29,5 +29,21 @@ "valid": false } ] + }, + { + "description": "minLength validation with a decimal", + "schema": {"minLength": 2.0}, + "tests": [ + { + "description": "longer is valid", + "data": "foo", + "valid": true + }, + { + "description": "too short is invalid", + "data": "f", + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/minProperties.json b/json/tests/draft2020-12/minProperties.json index 49a0726..9f74f78 100644 --- a/json/tests/draft2020-12/minProperties.json +++ b/json/tests/draft2020-12/minProperties.json @@ -34,5 +34,21 @@ "valid": true } ] + }, + { + "description": "minProperties validation with a decimal", + "schema": {"minProperties": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "too short is invalid", + "data": {}, + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/optional/dependencies-compatibility.json b/json/tests/draft2020-12/optional/dependencies-compatibility.json new file mode 100644 index 0000000..6eafaf0 --- /dev/null +++ b/json/tests/draft2020-12/optional/dependencies-compatibility.json @@ -0,0 +1,269 @@ +[ + { + "description": "single dependency", + "schema": {"dependencies": {"bar": ["foo"]}}, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependant", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "with dependency", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "empty dependents", + "schema": {"dependencies": {"bar": []}}, + "tests": [ + { + "description": "empty object", + "data": {}, + "valid": true + }, + { + "description": "object with one property", + "data": {"bar": 2}, + "valid": true + }, + { + "description": "non-object is valid", + "data": 1, + "valid": true + } + ] + }, + { + "description": "multiple dependents required", + "schema": {"dependencies": {"quux": ["foo", "bar"]}}, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependants", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "with dependencies", + "data": {"foo": 1, "bar": 2, "quux": 3}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"foo": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing other dependency", + "data": {"bar": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing both dependencies", + "data": {"quux": 1}, + "valid": false + } + ] + }, + { + "description": "dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\nbar": ["foo\rbar"], + "foo\"bar": ["foo'bar"] + } + }, + "tests": [ + { + "description": "CRLF", + "data": { + "foo\nbar": 1, + "foo\rbar": 2 + }, + "valid": true + }, + { + "description": "quoted quotes", + "data": { + "foo'bar": 1, + "foo\"bar": 2 + }, + "valid": true + }, + { + "description": "CRLF missing dependent", + "data": { + "foo\nbar": 1, + "foo": 2 + }, + "valid": false + }, + { + "description": "quoted quotes missing dependent", + "data": { + "foo\"bar": 2 + }, + "valid": false + } + ] + }, + { + "description": "single schema dependency", + "schema": { + "dependencies": { + "bar": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"type": "integer"} + } + } + } + }, + "tests": [ + { + "description": "valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "no dependency", + "data": {"foo": "quux"}, + "valid": true + }, + { + "description": "wrong type", + "data": {"foo": "quux", "bar": 2}, + "valid": false + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": false + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "boolean subschemas", + "schema": { + "dependencies": { + "foo": true, + "bar": false + } + }, + "tests": [ + { + "description": "object with property having schema true is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "object with property having schema false is invalid", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "object with both properties is invalid", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "schema dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\tbar": {"minProperties": 4}, + "foo'bar": {"required": ["foo\"bar"]} + } + }, + "tests": [ + { + "description": "quoted tab", + "data": { + "foo\tbar": 1, + "a": 2, + "b": 3, + "c": 4 + }, + "valid": true + }, + { + "description": "quoted quote", + "data": { + "foo'bar": {"foo\"bar": 1} + }, + "valid": false + }, + { + "description": "quoted tab invalid under dependent schema", + "data": { + "foo\tbar": 1, + "a": 2 + }, + "valid": false + }, + { + "description": "quoted quote invalid under dependent schema", + "data": {"foo'bar": 1}, + "valid": false + } + ] + } +] diff --git a/json/tests/draft2020-12/ref.json b/json/tests/draft2020-12/ref.json index 8a65e51..122ff75 100644 --- a/json/tests/draft2020-12/ref.json +++ b/json/tests/draft2020-12/ref.json @@ -577,5 +577,70 @@ "valid": false } ] + }, + { + "description": "order of evaluation: $id and $ref", + "schema": { + "$comment": "$id must be evaluated before $ref to get the proper $ref destination", + "$id": "/ref-and-id1/base.json", + "$ref": "int.json", + "$defs": { + "bigint": { + "$comment": "canonical uri: /ref-and-id1/int.json", + "$id": "int.json", + "maximum": 10 + }, + "smallint": { + "$comment": "canonical uri: /ref-and-id1-int.json", + "$id": "/ref-and-id1-int.json", + "maximum": 2 + } + } + }, + "tests": [ + { + "description": "data is valid against first definition", + "data": 5, + "valid": true + }, + { + "description": "data is invalid against first definition", + "data": 50, + "valid": false + } + ] + }, + { + "description": "order of evaluation: $id and $anchor and $ref", + "schema": { + "$comment": "$id must be evaluated before $ref to get the proper $ref destination", + "$id": "/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", + "$anchor": "bigint", + "maximum": 10 + }, + "smallint": { + "$comment": "canonical uri: /ref-and-id2#/$defs/smallint; another valid uri for this location: /ref-and-id2/#bigint", + "$id": "/ref-and-id2/", + "$anchor": "bigint", + "maximum": 2 + } + } + }, + "tests": [ + { + "description": "data is valid against first definition", + "data": 5, + "valid": true + }, + { + "description": "data is invalid against first definition", + "data": 50, + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/refRemote.json b/json/tests/draft2020-12/refRemote.json index f122864..0a5e484 100644 --- a/json/tests/draft2020-12/refRemote.json +++ b/json/tests/draft2020-12/refRemote.json @@ -190,7 +190,7 @@ { "description": "Location-independent identifier in remote ref", "schema": { - "$ref": "http://localhost:1234/locationIndependentIdentifier.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/locationIndependentIdentifier.json#/$defs/refToInteger" }, "tests": [ { diff --git a/json/tests/draft6/id.json b/json/tests/draft6/id.json index b58e0d0..b03248b 100644 --- a/json/tests/draft6/id.json +++ b/json/tests/draft6/id.json @@ -48,6 +48,67 @@ "valid": false } ] + }, + { + "description": "non-schema object containing a plain-name $id property", + "schema": { + "$defs": { + "const_not_anchor": { + "const": { + "$id": "#not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] } - ] diff --git a/json/tests/draft6/maxItems.json b/json/tests/draft6/maxItems.json index 3b53a6b..f0c36ab 100644 --- a/json/tests/draft6/maxItems.json +++ b/json/tests/draft6/maxItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "maxItems validation with a decimal", + "schema": {"maxItems": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": [1], + "valid": true + }, + { + "description": "too long is invalid", + "data": [1, 2, 3], + "valid": false + } + ] } ] diff --git a/json/tests/draft6/maxLength.json b/json/tests/draft6/maxLength.json index 811d35b..748b4da 100644 --- a/json/tests/draft6/maxLength.json +++ b/json/tests/draft6/maxLength.json @@ -29,5 +29,21 @@ "valid": true } ] + }, + { + "description": "maxLength validation with a decimal", + "schema": {"maxLength": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": "f", + "valid": true + }, + { + "description": "too long is invalid", + "data": "foo", + "valid": false + } + ] } ] diff --git a/json/tests/draft6/maxProperties.json b/json/tests/draft6/maxProperties.json index aa7209f..acec142 100644 --- a/json/tests/draft6/maxProperties.json +++ b/json/tests/draft6/maxProperties.json @@ -36,6 +36,22 @@ ] }, { + "description": "maxProperties validation with a decimal", + "schema": {"maxProperties": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "too long is invalid", + "data": {"foo": 1, "bar": 2, "baz": 3}, + "valid": false + } + ] + }, + { "description": "maxProperties = 0 means the object is empty", "schema": { "maxProperties": 0 }, "tests": [ diff --git a/json/tests/draft6/minItems.json b/json/tests/draft6/minItems.json index ed51188..d3b1872 100644 --- a/json/tests/draft6/minItems.json +++ b/json/tests/draft6/minItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "minItems validation with a decimal", + "schema": {"minItems": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "too short is invalid", + "data": [], + "valid": false + } + ] } ] diff --git a/json/tests/draft6/minLength.json b/json/tests/draft6/minLength.json index 3f09158..64db948 100644 --- a/json/tests/draft6/minLength.json +++ b/json/tests/draft6/minLength.json @@ -29,5 +29,21 @@ "valid": false } ] + }, + { + "description": "minLength validation with a decimal", + "schema": {"minLength": 2.0}, + "tests": [ + { + "description": "longer is valid", + "data": "foo", + "valid": true + }, + { + "description": "too short is invalid", + "data": "f", + "valid": false + } + ] } ] diff --git a/json/tests/draft6/minProperties.json b/json/tests/draft6/minProperties.json index 49a0726..9f74f78 100644 --- a/json/tests/draft6/minProperties.json +++ b/json/tests/draft6/minProperties.json @@ -34,5 +34,21 @@ "valid": true } ] + }, + { + "description": "minProperties validation with a decimal", + "schema": {"minProperties": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "too short is invalid", + "data": {}, + "valid": false + } + ] } ] diff --git a/json/tests/draft7/id.json b/json/tests/draft7/id.json index b58e0d0..b03248b 100644 --- a/json/tests/draft7/id.json +++ b/json/tests/draft7/id.json @@ -48,6 +48,67 @@ "valid": false } ] + }, + { + "description": "non-schema object containing a plain-name $id property", + "schema": { + "$defs": { + "const_not_anchor": { + "const": { + "$id": "#not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] } - ] diff --git a/json/tests/draft7/maxItems.json b/json/tests/draft7/maxItems.json index 3b53a6b..f0c36ab 100644 --- a/json/tests/draft7/maxItems.json +++ b/json/tests/draft7/maxItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "maxItems validation with a decimal", + "schema": {"maxItems": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": [1], + "valid": true + }, + { + "description": "too long is invalid", + "data": [1, 2, 3], + "valid": false + } + ] } ] diff --git a/json/tests/draft7/maxLength.json b/json/tests/draft7/maxLength.json index 811d35b..748b4da 100644 --- a/json/tests/draft7/maxLength.json +++ b/json/tests/draft7/maxLength.json @@ -29,5 +29,21 @@ "valid": true } ] + }, + { + "description": "maxLength validation with a decimal", + "schema": {"maxLength": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": "f", + "valid": true + }, + { + "description": "too long is invalid", + "data": "foo", + "valid": false + } + ] } ] diff --git a/json/tests/draft7/maxProperties.json b/json/tests/draft7/maxProperties.json index aa7209f..acec142 100644 --- a/json/tests/draft7/maxProperties.json +++ b/json/tests/draft7/maxProperties.json @@ -36,6 +36,22 @@ ] }, { + "description": "maxProperties validation with a decimal", + "schema": {"maxProperties": 2.0}, + "tests": [ + { + "description": "shorter is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "too long is invalid", + "data": {"foo": 1, "bar": 2, "baz": 3}, + "valid": false + } + ] + }, + { "description": "maxProperties = 0 means the object is empty", "schema": { "maxProperties": 0 }, "tests": [ diff --git a/json/tests/draft7/minItems.json b/json/tests/draft7/minItems.json index ed51188..d3b1872 100644 --- a/json/tests/draft7/minItems.json +++ b/json/tests/draft7/minItems.json @@ -24,5 +24,21 @@ "valid": true } ] + }, + { + "description": "minItems validation with a decimal", + "schema": {"minItems": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "too short is invalid", + "data": [], + "valid": false + } + ] } ] diff --git a/json/tests/draft7/minLength.json b/json/tests/draft7/minLength.json index 3f09158..64db948 100644 --- a/json/tests/draft7/minLength.json +++ b/json/tests/draft7/minLength.json @@ -29,5 +29,21 @@ "valid": false } ] + }, + { + "description": "minLength validation with a decimal", + "schema": {"minLength": 2.0}, + "tests": [ + { + "description": "longer is valid", + "data": "foo", + "valid": true + }, + { + "description": "too short is invalid", + "data": "f", + "valid": false + } + ] } ] diff --git a/json/tests/draft7/minProperties.json b/json/tests/draft7/minProperties.json index 49a0726..9f74f78 100644 --- a/json/tests/draft7/minProperties.json +++ b/json/tests/draft7/minProperties.json @@ -34,5 +34,21 @@ "valid": true } ] + }, + { + "description": "minProperties validation with a decimal", + "schema": {"minProperties": 1.0}, + "tests": [ + { + "description": "longer is valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "too short is invalid", + "data": {}, + "valid": false + } + ] } ] |