From 45bda8b7b31a69410832b2e06ff1d21792128036 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Wed, 20 May 2020 15:56:04 -0700 Subject: [PATCH 01/13] some tests for keywords added in later drafts these are mostly the same as tests from draft2019-09, with the results adjusted to accomodate for the keywords not being recognized. In most cases this results in validation always being true, but in some cases (such as contains + minContains) the results from existing keywords change their outcomes as well. --- tests/draft4/unrecognized-keywords.json | 346 ++++++++++++++++++++++++ tests/draft6/unrecognized-keywords.json | 310 +++++++++++++++++++++ tests/draft7/unrecognized-keywords.json | 277 +++++++++++++++++++ 3 files changed, 933 insertions(+) create mode 100644 tests/draft4/unrecognized-keywords.json create mode 100644 tests/draft6/unrecognized-keywords.json create mode 100644 tests/draft7/unrecognized-keywords.json diff --git a/tests/draft4/unrecognized-keywords.json b/tests/draft4/unrecognized-keywords.json new file mode 100644 index 00000000..03bb73d4 --- /dev/null +++ b/tests/draft4/unrecognized-keywords.json @@ -0,0 +1,346 @@ +[ + { + "description": "$anchor: location-independent identifier", + "schema": { + "allOf": [{ + "$ref": "#foo" + }], + "$defs": { + "A": { + "$anchor": "foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "cannot match: $ref is not found", + "valid": false + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "$id: Location-independent identifier", + "schema": { + "allOf": [{ + "$ref": "#foo" + }], + "$defs": { + "A": { + "$id": "#foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "match", + "valid": true + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "dependentSchemas: single dependency", + "schema": { + "dependentSchemas": { + "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": true + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": true + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": true + } + ] + }, + { + "description": "dependentRequired: single dependency", + "schema": {"dependentRequired": {"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": true + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "unevaluatedItems false", + "schema": { + "type": "array", + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": [], + "valid": true + }, + { + "description": "with unevaluated items", + "data": ["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": true + } + ] + }, + { + "description": "maxContains with contains", + "schema": { + "contains": {"const": 1}, + "maxContains": 1 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": true + }, + { + "description": "all elements match, valid maxContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "all elements match, invalid maxContains", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid maxContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "some elements match, invalid maxContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains=2 with contains", + "schema": { + "contains": {"const": 1}, + "minContains": 2 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": true + }, + { + "description": "all elements match, invalid minContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "some elements match, invalid minContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (exactly as needed)", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (more than needed)", + "data": [ 1, 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid minContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains = 0", + "schema": { + "contains": {"const": 1}, + "minContains": 0 + }, + "tests": [ + { + "description": "empty array is invalid", + "data": [ ], + "valid": true + }, + { + "description": "minContains = 0 would make contains always pass", + "data": [ 2 ], + "valid": true + } + ] + }, + { + "description": "if with boolean schema true", + "schema": { "if": true, "then": { "const": "then" }, "else": { "const": "else" } }, + "tests": [ + { + "description": "boolean schema true in if (invalid when supported)", + "data": "then", + "valid": true + }, + { + "description": "boolean schema true in if (valid when supported)", + "data": "else", + "valid": true + } + ] + }, + { + "description": "if with boolean schema false", + "schema": { "if": false, "then": { "const": "then" }, "else": { "const": "else" } }, + "tests": [ + { + "description": "boolean schema false in if (invalid when supported)", + "data": "then", + "valid": true + }, + { + "description": "boolean schema false in if (valid when supported)", + "data": "else", + "valid": true + } + ] + }, + { + "description": "propertyNames with boolean schema false", + "schema": {"propertyNames": false}, + "tests": [ + { + "description": "object with any properties is invalid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "const validation", + "schema": {"const": 2}, + "tests": [ + { + "description": "same value is valid", + "data": 2, + "valid": true + }, + { + "description": "another value is invalid", + "data": 5, + "valid": true + }, + { + "description": "another type is invalid", + "data": "a", + "valid": true + } + ] + } +] diff --git a/tests/draft6/unrecognized-keywords.json b/tests/draft6/unrecognized-keywords.json new file mode 100644 index 00000000..9e51d060 --- /dev/null +++ b/tests/draft6/unrecognized-keywords.json @@ -0,0 +1,310 @@ +[ + { + "description": "$anchor: location-independent identifier", + "schema": { + "allOf": [{ + "$ref": "#foo" + }], + "$defs": { + "A": { + "$anchor": "foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "cannot match: $ref is not found", + "valid": false + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "$id: Location-independent identifier", + "schema": { + "allOf": [{ + "$ref": "#foo" + }], + "$defs": { + "A": { + "$id": "#foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "match", + "valid": true + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "dependentSchemas: single dependency", + "schema": { + "dependentSchemas": { + "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": true + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": true + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": true + } + ] + }, + { + "description": "dependentRequired: single dependency", + "schema": {"dependentRequired": {"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": true + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "unevaluatedItems false", + "schema": { + "type": "array", + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": [], + "valid": true + }, + { + "description": "with unevaluated items", + "data": ["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": true + } + ] + }, + { + "description": "maxContains with contains", + "schema": { + "contains": {"const": 1}, + "maxContains": 1 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": false + }, + { + "description": "all elements match, valid maxContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "all elements match, invalid maxContains", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid maxContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "some elements match, invalid maxContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains=2 with contains", + "schema": { + "contains": {"const": 1}, + "minContains": 2 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": false + }, + { + "description": "all elements match, invalid minContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "some elements match, invalid minContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (exactly as needed)", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (more than needed)", + "data": [ 1, 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid minContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains = 0", + "schema": { + "contains": {"const": 1}, + "minContains": 0 + }, + "tests": [ + { + "description": "empty array is invalid", + "data": [ ], + "valid": false + }, + { + "description": "minContains = 0 would make contains always pass", + "data": [ 2 ], + "valid": false + } + ] + }, + { + "description": "if with boolean schema true", + "schema": { "if": true, "then": { "const": "then" }, "else": { "const": "else" } }, + "tests": [ + { + "description": "boolean schema true in if (invalid when supported)", + "data": "then", + "valid": true + }, + { + "description": "boolean schema true in if (valid when supported)", + "data": "else", + "valid": true + } + ] + }, + { + "description": "if with boolean schema false", + "schema": { "if": false, "then": { "const": "then" }, "else": { "const": "else" } }, + "tests": [ + { + "description": "boolean schema false in if (invalid when supported)", + "data": "then", + "valid": true + }, + { + "description": "boolean schema false in if (valid when supported)", + "data": "else", + "valid": true + } + ] + } +] + diff --git a/tests/draft7/unrecognized-keywords.json b/tests/draft7/unrecognized-keywords.json new file mode 100644 index 00000000..f5aac2a0 --- /dev/null +++ b/tests/draft7/unrecognized-keywords.json @@ -0,0 +1,277 @@ +[ + { + "description": "$anchor: location-independent identifier", + "schema": { + "allOf": [{ + "$ref": "#foo" + }], + "$defs": { + "A": { + "$anchor": "foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "cannot match: $ref is not found", + "valid": false + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "$id: Location-independent identifier", + "schema": { + "allOf": [{ + "$ref": "#foo" + }], + "$defs": { + "A": { + "$id": "#foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "match", + "valid": true + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "dependentSchemas: single dependency", + "schema": { + "dependentSchemas": { + "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": true + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": true + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": true + } + ] + }, + { + "description": "dependentRequired: single dependency", + "schema": {"dependentRequired": {"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": true + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "unevaluatedItems false", + "schema": { + "type": "array", + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": [], + "valid": true + }, + { + "description": "with unevaluated items", + "data": ["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": true + } + ] + }, + { + "description": "maxContains with contains", + "schema": { + "contains": {"const": 1}, + "maxContains": 1 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": false + }, + { + "description": "all elements match, valid maxContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "all elements match, invalid maxContains", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid maxContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "some elements match, invalid maxContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains=2 with contains", + "schema": { + "contains": {"const": 1}, + "minContains": 2 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": false + }, + { + "description": "all elements match, invalid minContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "some elements match, invalid minContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (exactly as needed)", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (more than needed)", + "data": [ 1, 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid minContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains = 0", + "schema": { + "contains": {"const": 1}, + "minContains": 0 + }, + "tests": [ + { + "description": "empty array is invalid", + "data": [ ], + "valid": false + }, + { + "description": "minContains = 0 would make contains always pass", + "data": [ 2 ], + "valid": false + } + ] + } +] From e99f7f453e58586ad7b044605c3fd46677ff7920 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 4 Jun 2020 08:31:46 -0700 Subject: [PATCH 02/13] rename files to future-keywords.json --- tests/draft4/{unrecognized-keywords.json => future-keywords.json} | 0 tests/draft6/{unrecognized-keywords.json => future-keywords.json} | 0 tests/draft7/{unrecognized-keywords.json => future-keywords.json} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tests/draft4/{unrecognized-keywords.json => future-keywords.json} (100%) rename tests/draft6/{unrecognized-keywords.json => future-keywords.json} (100%) rename tests/draft7/{unrecognized-keywords.json => future-keywords.json} (100%) diff --git a/tests/draft4/unrecognized-keywords.json b/tests/draft4/future-keywords.json similarity index 100% rename from tests/draft4/unrecognized-keywords.json rename to tests/draft4/future-keywords.json diff --git a/tests/draft6/unrecognized-keywords.json b/tests/draft6/future-keywords.json similarity index 100% rename from tests/draft6/unrecognized-keywords.json rename to tests/draft6/future-keywords.json diff --git a/tests/draft7/unrecognized-keywords.json b/tests/draft7/future-keywords.json similarity index 100% rename from tests/draft7/unrecognized-keywords.json rename to tests/draft7/future-keywords.json From 8652f95c7f98a48e2c8010f4fa6fd9f22b558ff5 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 4 Jun 2020 08:34:34 -0700 Subject: [PATCH 03/13] very basic test of $dynamicRef --- tests/draft2019-09/future-keywords.json | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/draft2019-09/future-keywords.json diff --git a/tests/draft2019-09/future-keywords.json b/tests/draft2019-09/future-keywords.json new file mode 100644 index 00000000..75f7549b --- /dev/null +++ b/tests/draft2019-09/future-keywords.json @@ -0,0 +1,33 @@ +[ + { + "description": "$dynamicRef", + "schema": { + "properties": { + "foo": {"$dynamicRef": "#"} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": {"foo": {"foo": false}}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": false}, + "valid": false + }, + { + "description": "recursive mismatch", + "data": {"foo": {"bar": false}}, + "valid": false + } + ] + } +} From fc7c9d63f2c2b529d95b4495e6256bd745339fc9 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 4 Jun 2020 09:24:44 -0700 Subject: [PATCH 04/13] squash - fix 2019-09 future-keywords --- tests/draft2019-09/future-keywords.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/draft2019-09/future-keywords.json b/tests/draft2019-09/future-keywords.json index 75f7549b..83f67362 100644 --- a/tests/draft2019-09/future-keywords.json +++ b/tests/draft2019-09/future-keywords.json @@ -1,6 +1,6 @@ [ { - "description": "$dynamicRef", + "description": "$dynamicRef without $dynamicAnchor works like $ref", "schema": { "properties": { "foo": {"$dynamicRef": "#"} @@ -24,10 +24,10 @@ "valid": false }, { - "description": "recursive mismatch", + "description": "recursive mismatch (but $dynamicRef is ignored)", "data": {"foo": {"bar": false}}, - "valid": false + "valid": true } ] } -} +] From 3647c03f8ceac50e7fe3cc0932f3c510bdfd0765 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 4 Jun 2020 13:39:50 -0700 Subject: [PATCH 05/13] squash: add $recursiveRef tests from #391 --- tests/draft4/future-keywords.json | 132 +++++++++++++++++++++++++++++ tests/draft6/future-keywords.json | 133 +++++++++++++++++++++++++++++- tests/draft7/future-keywords.json | 132 +++++++++++++++++++++++++++++ 3 files changed, 396 insertions(+), 1 deletion(-) diff --git a/tests/draft4/future-keywords.json b/tests/draft4/future-keywords.json index 03bb73d4..a31b9d32 100644 --- a/tests/draft4/future-keywords.json +++ b/tests/draft4/future-keywords.json @@ -342,5 +342,137 @@ "valid": true } ] + }, + { + "description": "$recursiveRef without $recursiveAnchor works like $ref", + "schema": { + "properties": { + "foo": { "$recursiveRef": "#" } + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": { "foo": { "foo": false } }, + "valid": true + }, + { + "description": "mismatch", + "data": { "bar": false }, + "valid": false + }, + { + "description": "recursive mismatch", + "data": { "foo": { "bar": false } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef without using nesting", + "schema": { + "$id": "http://localhost:4242", + "$defs": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/$defs/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer does not match as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, properties match with inner definition", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, no match", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef with nesting", + "schema": { + "$id": "http://localhost:4242", + "$recursiveAnchor": true, + "$defs": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/$defs/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer now matches as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, properties match with inner definition", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, properties match with $recursiveRef", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] } ] diff --git a/tests/draft6/future-keywords.json b/tests/draft6/future-keywords.json index 9e51d060..63aa160b 100644 --- a/tests/draft6/future-keywords.json +++ b/tests/draft6/future-keywords.json @@ -305,6 +305,137 @@ "valid": true } ] + }, + { + "description": "$recursiveRef without $recursiveAnchor works like $ref", + "schema": { + "properties": { + "foo": { "$recursiveRef": "#" } + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": { "foo": { "foo": false } }, + "valid": true + }, + { + "description": "mismatch", + "data": { "bar": false }, + "valid": false + }, + { + "description": "recursive mismatch", + "data": { "foo": { "bar": false } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef without using nesting", + "schema": { + "$id": "http://localhost:4242", + "$defs": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/$defs/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer does not match as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, properties match with inner definition", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, no match", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef with nesting", + "schema": { + "$id": "http://localhost:4242", + "$recursiveAnchor": true, + "$defs": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/$defs/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer now matches as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, properties match with inner definition", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, properties match with $recursiveRef", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] } ] - diff --git a/tests/draft7/future-keywords.json b/tests/draft7/future-keywords.json index f5aac2a0..000667bb 100644 --- a/tests/draft7/future-keywords.json +++ b/tests/draft7/future-keywords.json @@ -273,5 +273,137 @@ "valid": false } ] + }, + { + "description": "$recursiveRef without $recursiveAnchor works like $ref", + "schema": { + "properties": { + "foo": { "$recursiveRef": "#" } + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": { "foo": { "foo": false } }, + "valid": true + }, + { + "description": "mismatch", + "data": { "bar": false }, + "valid": false + }, + { + "description": "recursive mismatch", + "data": { "foo": { "bar": false } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef without using nesting", + "schema": { + "$id": "http://localhost:4242", + "$defs": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/$defs/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer does not match as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, properties match with inner definition", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, no match", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef with nesting", + "schema": { + "$id": "http://localhost:4242", + "$recursiveAnchor": true, + "$defs": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/$defs/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer now matches as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, properties match with inner definition", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, properties match with $recursiveRef", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] } ] From 96332fd0ac510c26909d6691ab3df51a238d70f3 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Sat, 6 Jun 2020 17:33:02 -0700 Subject: [PATCH 06/13] squash: add prefixItems: another new 2020-0X keyword --- tests/draft2019-09/future-keywords.json | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/draft2019-09/future-keywords.json b/tests/draft2019-09/future-keywords.json index 83f67362..b70adc86 100644 --- a/tests/draft2019-09/future-keywords.json +++ b/tests/draft2019-09/future-keywords.json @@ -29,5 +29,50 @@ "valid": true } ] + }, + { + "description": "prefixItems: an array of schemas for items", + "schema": { + "items": [ + {"type": "integer"}, + {"type": "string"} + ] + }, + "tests": [ + { + "description": "correct types", + "data": [ 1, "foo" ], + "valid": true + }, + { + "description": "wrong types", + "data": [ "foo", 1 ], + "valid": true + }, + { + "description": "incomplete array of items", + "data": [ 1 ], + "valid": true + }, + { + "description": "array with additional items", + "data": [ 1, "foo", true ], + "valid": true + }, + { + "description": "empty array", + "data": [ ], + "valid": true + }, + { + "description": "JavaScript pseudo-array is valid", + "data": { + "0": "invalid", + "1": "valid", + "length": 2 + }, + "valid": true + } + ] } ] From da552bb51b7146288a15ddd6087fd9351ba34800 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 11 Jun 2020 08:53:07 -0700 Subject: [PATCH 07/13] squash: remove tests of $anchor and $ref --- tests/draft4/future-keywords.json | 52 ------------------------------- tests/draft6/future-keywords.json | 52 ------------------------------- tests/draft7/future-keywords.json | 52 ------------------------------- 3 files changed, 156 deletions(-) diff --git a/tests/draft4/future-keywords.json b/tests/draft4/future-keywords.json index a31b9d32..ed3471ba 100644 --- a/tests/draft4/future-keywords.json +++ b/tests/draft4/future-keywords.json @@ -1,56 +1,4 @@ [ - { - "description": "$anchor: location-independent identifier", - "schema": { - "allOf": [{ - "$ref": "#foo" - }], - "$defs": { - "A": { - "$anchor": "foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "cannot match: $ref is not found", - "valid": false - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { - "description": "$id: Location-independent identifier", - "schema": { - "allOf": [{ - "$ref": "#foo" - }], - "$defs": { - "A": { - "$id": "#foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, { "description": "dependentSchemas: single dependency", "schema": { diff --git a/tests/draft6/future-keywords.json b/tests/draft6/future-keywords.json index 63aa160b..4c5c973b 100644 --- a/tests/draft6/future-keywords.json +++ b/tests/draft6/future-keywords.json @@ -1,56 +1,4 @@ [ - { - "description": "$anchor: location-independent identifier", - "schema": { - "allOf": [{ - "$ref": "#foo" - }], - "$defs": { - "A": { - "$anchor": "foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "cannot match: $ref is not found", - "valid": false - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { - "description": "$id: Location-independent identifier", - "schema": { - "allOf": [{ - "$ref": "#foo" - }], - "$defs": { - "A": { - "$id": "#foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, { "description": "dependentSchemas: single dependency", "schema": { diff --git a/tests/draft7/future-keywords.json b/tests/draft7/future-keywords.json index 000667bb..b59dd754 100644 --- a/tests/draft7/future-keywords.json +++ b/tests/draft7/future-keywords.json @@ -1,56 +1,4 @@ [ - { - "description": "$anchor: location-independent identifier", - "schema": { - "allOf": [{ - "$ref": "#foo" - }], - "$defs": { - "A": { - "$anchor": "foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "cannot match: $ref is not found", - "valid": false - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { - "description": "$id: Location-independent identifier", - "schema": { - "allOf": [{ - "$ref": "#foo" - }], - "$defs": { - "A": { - "$id": "#foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, { "description": "dependentSchemas: single dependency", "schema": { From 3484f74370375007982c141109339c9b70241e39 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 11 Jun 2020 08:53:20 -0700 Subject: [PATCH 08/13] squash: $defs - definitions --- tests/draft4/future-keywords.json | 12 ++++++------ tests/draft6/future-keywords.json | 8 ++++---- tests/draft7/future-keywords.json | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/draft4/future-keywords.json b/tests/draft4/future-keywords.json index ed3471ba..1c319fa1 100644 --- a/tests/draft4/future-keywords.json +++ b/tests/draft4/future-keywords.json @@ -326,7 +326,7 @@ "description": "$recursiveRef without using nesting", "schema": { "$id": "http://localhost:4242", - "$defs": { + "definitions": { "myobject": { "$id": "myobject.json", "$recursiveAnchor": true, @@ -341,7 +341,7 @@ }, "anyOf": [ { "type": "integer" }, - { "$ref": "#/$defs/myobject" } + { "$ref": "#/definitions/myobject" } ] }, "tests": [ @@ -361,12 +361,12 @@ "valid": true }, { - "description": "two levels, properties match with inner definition", + "description": "two levels, additionalProperties always matches", "data": { "foo": { "bar": "hi" } }, "valid": true }, { - "description": "two levels, no match", + "description": "two levels, additionalProperties always matches", "data": { "foo": { "bar": 1 } }, "valid": true } @@ -377,7 +377,7 @@ "schema": { "$id": "http://localhost:4242", "$recursiveAnchor": true, - "$defs": { + "definitions": { "myobject": { "$id": "myobject.json", "$recursiveAnchor": true, @@ -392,7 +392,7 @@ }, "anyOf": [ { "type": "integer" }, - { "$ref": "#/$defs/myobject" } + { "$ref": "#/definitions/myobject" } ] }, "tests": [ diff --git a/tests/draft6/future-keywords.json b/tests/draft6/future-keywords.json index 4c5c973b..3988692d 100644 --- a/tests/draft6/future-keywords.json +++ b/tests/draft6/future-keywords.json @@ -289,7 +289,7 @@ "description": "$recursiveRef without using nesting", "schema": { "$id": "http://localhost:4242", - "$defs": { + "definitions": { "myobject": { "$id": "myobject.json", "$recursiveAnchor": true, @@ -304,7 +304,7 @@ }, "anyOf": [ { "type": "integer" }, - { "$ref": "#/$defs/myobject" } + { "$ref": "#/definitions/myobject" } ] }, "tests": [ @@ -340,7 +340,7 @@ "schema": { "$id": "http://localhost:4242", "$recursiveAnchor": true, - "$defs": { + "definitions": { "myobject": { "$id": "myobject.json", "$recursiveAnchor": true, @@ -355,7 +355,7 @@ }, "anyOf": [ { "type": "integer" }, - { "$ref": "#/$defs/myobject" } + { "$ref": "#/definitions/myobject" } ] }, "tests": [ diff --git a/tests/draft7/future-keywords.json b/tests/draft7/future-keywords.json index b59dd754..721ebd6e 100644 --- a/tests/draft7/future-keywords.json +++ b/tests/draft7/future-keywords.json @@ -257,7 +257,7 @@ "description": "$recursiveRef without using nesting", "schema": { "$id": "http://localhost:4242", - "$defs": { + "definitions": { "myobject": { "$id": "myobject.json", "$recursiveAnchor": true, @@ -272,7 +272,7 @@ }, "anyOf": [ { "type": "integer" }, - { "$ref": "#/$defs/myobject" } + { "$ref": "#/definitions/myobject" } ] }, "tests": [ @@ -308,7 +308,7 @@ "schema": { "$id": "http://localhost:4242", "$recursiveAnchor": true, - "$defs": { + "definitions": { "myobject": { "$id": "myobject.json", "$recursiveAnchor": true, @@ -323,7 +323,7 @@ }, "anyOf": [ { "type": "integer" }, - { "$ref": "#/$defs/myobject" } + { "$ref": "#/definitions/myobject" } ] }, "tests": [ From 05f81c0168b84137a5c7e56daaf765e0b6aa779f Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 11 Jun 2020 09:50:36 -0700 Subject: [PATCH 09/13] squash: fix test names --- tests/draft4/future-keywords.json | 4 ++-- tests/draft6/future-keywords.json | 4 ++-- tests/draft7/future-keywords.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/draft4/future-keywords.json b/tests/draft4/future-keywords.json index 1c319fa1..65a8da45 100644 --- a/tests/draft4/future-keywords.json +++ b/tests/draft4/future-keywords.json @@ -361,12 +361,12 @@ "valid": true }, { - "description": "two levels, additionalProperties always matches", + "description": "two levels, additionalProperties always matches, 1", "data": { "foo": { "bar": "hi" } }, "valid": true }, { - "description": "two levels, additionalProperties always matches", + "description": "two levels, additionalProperties always matches, 2", "data": { "foo": { "bar": 1 } }, "valid": true } diff --git a/tests/draft6/future-keywords.json b/tests/draft6/future-keywords.json index 3988692d..30224298 100644 --- a/tests/draft6/future-keywords.json +++ b/tests/draft6/future-keywords.json @@ -324,12 +324,12 @@ "valid": true }, { - "description": "two levels, properties match with inner definition", + "description": "two levels, additionalProperties always matches, 1", "data": { "foo": { "bar": "hi" } }, "valid": true }, { - "description": "two levels, no match", + "description": "two levels, additionalProperties always matches, 2", "data": { "foo": { "bar": 1 } }, "valid": true } diff --git a/tests/draft7/future-keywords.json b/tests/draft7/future-keywords.json index 721ebd6e..7c02b4a2 100644 --- a/tests/draft7/future-keywords.json +++ b/tests/draft7/future-keywords.json @@ -292,12 +292,12 @@ "valid": true }, { - "description": "two levels, properties match with inner definition", + "description": "two levels, additionalProperties always matches, 1", "data": { "foo": { "bar": "hi" } }, "valid": true }, { - "description": "two levels, no match", + "description": "two levels, additionalProperties always matches, 2", "data": { "foo": { "bar": 1 } }, "valid": true } From 1994f7382b4ab6b0330abc9fa9de6abd1c164528 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 11 Jun 2020 09:50:57 -0700 Subject: [PATCH 10/13] sq - add $dynamic*, prefixItems to drafts 4,6,7 as well and fix keyword name --- tests/draft2019-09/future-keywords.json | 2 +- tests/draft4/future-keywords.json | 76 +++++++++++++++++++++++++ tests/draft6/future-keywords.json | 76 +++++++++++++++++++++++++ tests/draft7/future-keywords.json | 76 +++++++++++++++++++++++++ 4 files changed, 229 insertions(+), 1 deletion(-) diff --git a/tests/draft2019-09/future-keywords.json b/tests/draft2019-09/future-keywords.json index b70adc86..aecf99f1 100644 --- a/tests/draft2019-09/future-keywords.json +++ b/tests/draft2019-09/future-keywords.json @@ -33,7 +33,7 @@ { "description": "prefixItems: an array of schemas for items", "schema": { - "items": [ + "prefixItems": [ {"type": "integer"}, {"type": "string"} ] diff --git a/tests/draft4/future-keywords.json b/tests/draft4/future-keywords.json index 65a8da45..6f296ab8 100644 --- a/tests/draft4/future-keywords.json +++ b/tests/draft4/future-keywords.json @@ -1,4 +1,80 @@ [ + { + "description": "$dynamicRef without $dynamicAnchor works like $ref", + "schema": { + "properties": { + "foo": {"$dynamicRef": "#"} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": {"foo": {"foo": false}}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": false}, + "valid": false + }, + { + "description": "recursive mismatch (but $dynamicRef is ignored)", + "data": {"foo": {"bar": false}}, + "valid": true + } + ] + }, + { + "description": "prefixItems: an array of schemas for items", + "schema": { + "prefixItems": [ + {"type": "integer"}, + {"type": "string"} + ] + }, + "tests": [ + { + "description": "correct types", + "data": [ 1, "foo" ], + "valid": true + }, + { + "description": "wrong types", + "data": [ "foo", 1 ], + "valid": true + }, + { + "description": "incomplete array of items", + "data": [ 1 ], + "valid": true + }, + { + "description": "array with additional items", + "data": [ 1, "foo", true ], + "valid": true + }, + { + "description": "empty array", + "data": [ ], + "valid": true + }, + { + "description": "JavaScript pseudo-array is valid", + "data": { + "0": "invalid", + "1": "valid", + "length": 2 + }, + "valid": true + } + ] + }, { "description": "dependentSchemas: single dependency", "schema": { diff --git a/tests/draft6/future-keywords.json b/tests/draft6/future-keywords.json index 30224298..4aa54da5 100644 --- a/tests/draft6/future-keywords.json +++ b/tests/draft6/future-keywords.json @@ -1,4 +1,80 @@ [ + { + "description": "$dynamicRef without $dynamicAnchor works like $ref", + "schema": { + "properties": { + "foo": {"$dynamicRef": "#"} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": {"foo": {"foo": false}}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": false}, + "valid": false + }, + { + "description": "recursive mismatch (but $dynamicRef is ignored)", + "data": {"foo": {"bar": false}}, + "valid": true + } + ] + }, + { + "description": "prefixItems: an array of schemas for items", + "schema": { + "prefixItems": [ + {"type": "integer"}, + {"type": "string"} + ] + }, + "tests": [ + { + "description": "correct types", + "data": [ 1, "foo" ], + "valid": true + }, + { + "description": "wrong types", + "data": [ "foo", 1 ], + "valid": true + }, + { + "description": "incomplete array of items", + "data": [ 1 ], + "valid": true + }, + { + "description": "array with additional items", + "data": [ 1, "foo", true ], + "valid": true + }, + { + "description": "empty array", + "data": [ ], + "valid": true + }, + { + "description": "JavaScript pseudo-array is valid", + "data": { + "0": "invalid", + "1": "valid", + "length": 2 + }, + "valid": true + } + ] + }, { "description": "dependentSchemas: single dependency", "schema": { diff --git a/tests/draft7/future-keywords.json b/tests/draft7/future-keywords.json index 7c02b4a2..3cfee5f5 100644 --- a/tests/draft7/future-keywords.json +++ b/tests/draft7/future-keywords.json @@ -1,4 +1,80 @@ [ + { + "description": "$dynamicRef without $dynamicAnchor works like $ref", + "schema": { + "properties": { + "foo": {"$dynamicRef": "#"} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": {"foo": {"foo": false}}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": false}, + "valid": false + }, + { + "description": "recursive mismatch (but $dynamicRef is ignored)", + "data": {"foo": {"bar": false}}, + "valid": true + } + ] + }, + { + "description": "prefixItems: an array of schemas for items", + "schema": { + "prefixItems": [ + {"type": "integer"}, + {"type": "string"} + ] + }, + "tests": [ + { + "description": "correct types", + "data": [ 1, "foo" ], + "valid": true + }, + { + "description": "wrong types", + "data": [ "foo", 1 ], + "valid": true + }, + { + "description": "incomplete array of items", + "data": [ 1 ], + "valid": true + }, + { + "description": "array with additional items", + "data": [ 1, "foo", true ], + "valid": true + }, + { + "description": "empty array", + "data": [ ], + "valid": true + }, + { + "description": "JavaScript pseudo-array is valid", + "data": { + "0": "invalid", + "1": "valid", + "length": 2 + }, + "valid": true + } + ] + }, { "description": "dependentSchemas: single dependency", "schema": { From 9609877ad13ed7b2057df7a874d8c60871b0bcd1 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 11 Jun 2020 10:04:29 -0700 Subject: [PATCH 11/13] squash: fix minContains --- tests/draft4/future-keywords.json | 10 +++++----- tests/draft6/future-keywords.json | 2 +- tests/draft7/future-keywords.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/draft4/future-keywords.json b/tests/draft4/future-keywords.json index 6f296ab8..98976017 100644 --- a/tests/draft4/future-keywords.json +++ b/tests/draft4/future-keywords.json @@ -216,7 +216,7 @@ { "description": "empty data", "data": [ ], - "valid": true + "valid": false }, { "description": "all elements match, valid maxContains", @@ -250,7 +250,7 @@ { "description": "empty data", "data": [ ], - "valid": true + "valid": false }, { "description": "all elements match, invalid minContains", @@ -287,14 +287,14 @@ }, "tests": [ { - "description": "empty array is invalid", + "description": "empty array is valid with minContains=0", "data": [ ], - "valid": true + "valid": false }, { "description": "minContains = 0 would make contains always pass", "data": [ 2 ], - "valid": true + "valid": false } ] }, diff --git a/tests/draft6/future-keywords.json b/tests/draft6/future-keywords.json index 4aa54da5..af2f7913 100644 --- a/tests/draft6/future-keywords.json +++ b/tests/draft6/future-keywords.json @@ -287,7 +287,7 @@ }, "tests": [ { - "description": "empty array is invalid", + "description": "empty array is valid with minContains=0", "data": [ ], "valid": false }, diff --git a/tests/draft7/future-keywords.json b/tests/draft7/future-keywords.json index 3cfee5f5..2df84211 100644 --- a/tests/draft7/future-keywords.json +++ b/tests/draft7/future-keywords.json @@ -287,7 +287,7 @@ }, "tests": [ { - "description": "empty array is invalid", + "description": "empty array is valid with minContains=0", "data": [ ], "valid": false }, From 6f268ee41ab387cfed605bfd4ed270e4d2334d24 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 11 Jun 2020 10:14:24 -0700 Subject: [PATCH 12/13] squash: contains does not exist in draft4 --- tests/draft4/future-keywords.json | 46 ++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/tests/draft4/future-keywords.json b/tests/draft4/future-keywords.json index 98976017..0e0ee3ea 100644 --- a/tests/draft4/future-keywords.json +++ b/tests/draft4/future-keywords.json @@ -216,7 +216,7 @@ { "description": "empty data", "data": [ ], - "valid": false + "valid": true }, { "description": "all elements match, valid maxContains", @@ -250,7 +250,7 @@ { "description": "empty data", "data": [ ], - "valid": false + "valid": true }, { "description": "all elements match, invalid minContains", @@ -289,12 +289,12 @@ { "description": "empty array is valid with minContains=0", "data": [ ], - "valid": false + "valid": true }, { "description": "minContains = 0 would make contains always pass", "data": [ 2 ], - "valid": false + "valid": true } ] }, @@ -314,6 +314,44 @@ } ] }, + { + "description": "contains keyword validation", + "schema": { + "contains": {"minimum": 5} + }, + "tests": [ + { + "description": "array with item matching schema (5) is valid", + "data": [3, 4, 5], + "valid": true + }, + { + "description": "array with item matching schema (6) is valid", + "data": [3, 4, 6], + "valid": true + }, + { + "description": "array with two items matching schema (5, 6) is valid", + "data": [3, 4, 5, 6], + "valid": true + }, + { + "description": "array without items matching schema is invalid", + "data": [2, 3, 4], + "valid": false + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + }, + { + "description": "not array is valid", + "data": {}, + "valid": true + } + ] + }, { "description": "if with boolean schema false", "schema": { "if": false, "then": { "const": "then" }, "else": { "const": "else" } }, From c53a1f0ba8947fa01ebded668ba424fc99e06188 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 11 Jun 2020 11:35:48 -0700 Subject: [PATCH 13/13] squash: add $schema keyword to be clear that strict conformance is requested --- tests/draft2019-09/future-keywords.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/draft2019-09/future-keywords.json b/tests/draft2019-09/future-keywords.json index aecf99f1..a67b71e9 100644 --- a/tests/draft2019-09/future-keywords.json +++ b/tests/draft2019-09/future-keywords.json @@ -2,6 +2,7 @@ { "description": "$dynamicRef without $dynamicAnchor works like $ref", "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", "properties": { "foo": {"$dynamicRef": "#"} }, @@ -33,6 +34,7 @@ { "description": "prefixItems: an array of schemas for items", "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", "prefixItems": [ {"type": "integer"}, {"type": "string"}