diff options
author | Julian Berman <Julian@GrayVines.com> | 2020-08-13 18:44:47 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2020-08-13 18:44:47 -0400 |
commit | d3fcdeba06398394db4adfd1a87553b801d6c877 (patch) | |
tree | 1da5cc2421114d037b20a2d76747a0f604a8529d /json | |
parent | 444174d607ced66d38ef31fcc279b5cf06973c4b (diff) | |
parent | a57d8540bd272d913d57a37b45db3d9fe21a476b (diff) | |
download | jsonschema-d3fcdeba06398394db4adfd1a87553b801d6c877.tar.gz |
Merge commit 'a57d8540bd272d913d57a37b45db3d9fe21a476b' into master
* commit 'a57d8540bd272d913d57a37b45db3d9fe21a476b':
Squashed 'json/' changes from ea415537..86f52b87
Diffstat (limited to 'json')
25 files changed, 486 insertions, 16 deletions
diff --git a/json/bin/jsonschema_suite b/json/bin/jsonschema_suite index 9ccd8e8..628bc5d 100755 --- a/json/bin/jsonschema_suite +++ b/json/bin/jsonschema_suite @@ -50,7 +50,9 @@ REMOTES = { u"refToInteger": {u"$ref": u"#/$defs/integer"}, } }, - "folder/folderInteger.json": {u"type": u"integer"} + "baseUriChange/folderInteger.json": {u"type": u"integer"}, + "baseUriChangeFolder/folderInteger.json": {u"type": u"integer"}, + "baseUriChangeFolderInSubschema/folderInteger.json": {u"type": u"integer"}, } REMOTES_DIR = os.path.join(ROOT_DIR, "remotes") diff --git a/json/remotes/folder/folderInteger.json b/json/remotes/baseUriChange/folderInteger.json index 8b50ea3..8b50ea3 100644 --- a/json/remotes/folder/folderInteger.json +++ b/json/remotes/baseUriChange/folderInteger.json diff --git a/json/remotes/baseUriChangeFolder/folderInteger.json b/json/remotes/baseUriChangeFolder/folderInteger.json new file mode 100644 index 0000000..8b50ea3 --- /dev/null +++ b/json/remotes/baseUriChangeFolder/folderInteger.json @@ -0,0 +1,3 @@ +{ + "type": "integer" +} diff --git a/json/remotes/baseUriChangeFolderInSubschema/folderInteger.json b/json/remotes/baseUriChangeFolderInSubschema/folderInteger.json new file mode 100644 index 0000000..8b50ea3 --- /dev/null +++ b/json/remotes/baseUriChangeFolderInSubschema/folderInteger.json @@ -0,0 +1,3 @@ +{ + "type": "integer" +} diff --git a/json/tests/draft2019-09/const.json b/json/tests/draft2019-09/const.json index c53d04d..1c2cafc 100644 --- a/json/tests/draft2019-09/const.json +++ b/json/tests/draft2019-09/const.json @@ -126,6 +126,90 @@ ] }, { + "description": "const with [false] does not match [0]", + "schema": {"const": [false]}, + "tests": [ + { + "description": "[false] is valid", + "data": [false], + "valid": true + }, + { + "description": "[0] is invalid", + "data": [0], + "valid": false + }, + { + "description": "[0.0] is invalid", + "data": [0.0], + "valid": false + } + ] + }, + { + "description": "const with [true] does not match [1]", + "schema": {"const": [true]}, + "tests": [ + { + "description": "[true] is valid", + "data": [true], + "valid": true + }, + { + "description": "[1] is invalid", + "data": [1], + "valid": false + }, + { + "description": "[1.0] is invalid", + "data": [1.0], + "valid": false + } + ] + }, + { + "description": "const with {\"a\": false} does not match {\"a\": 0}", + "schema": {"const": {"a": false}}, + "tests": [ + { + "description": "{\"a\": false} is valid", + "data": {"a": false}, + "valid": true + }, + { + "description": "{\"a\": 0} is invalid", + "data": {"a": 0}, + "valid": false + }, + { + "description": "{\"a\": 0.0} is invalid", + "data": {"a": 0.0}, + "valid": false + } + ] + }, + { + "description": "const with {\"a\": true} does not match {\"a\": 1}", + "schema": {"const": {"a": true}}, + "tests": [ + { + "description": "{\"a\": true} is valid", + "data": {"a": true}, + "valid": true + }, + { + "description": "{\"a\": 1} is invalid", + "data": {"a": 1}, + "valid": false + }, + { + "description": "{\"a\": 1.0} is invalid", + "data": {"a": 1.0}, + "valid": false + } + ] + }, + { "description": "const with 0 does not match other zero-like types", "schema": {"const": 0}, "tests": [ diff --git a/json/tests/draft2019-09/optional/format/ipv6.json b/json/tests/draft2019-09/optional/format/ipv6.json index 9b0881e..2a08cb4 100644 --- a/json/tests/draft2019-09/optional/format/ipv6.json +++ b/json/tests/draft2019-09/optional/format/ipv6.json @@ -112,6 +112,41 @@ "description": "ipv4 segment must have 4 octets", "data": "1:2:3:4:1.2.3", "valid": false + }, + { + "description": "leading whitespace is invalid", + "data": " ::1", + "valid": false + }, + { + "description": "trailing whitespace is invalid", + "data": "::1 ", + "valid": false + }, + { + "description": "netmask is not a part of ipv6 address", + "data": "fe80::/64", + "valid": false + }, + { + "description": "zone id is not a part of ipv6 address", + "data": "fe80::a%eth1", + "valid": false + }, + { + "description": "a long valid ipv6", + "data": "1000:1000:1000:1000:1000:1000:255.255.255.255", + "valid": true + }, + { + "description": "a long invalid ipv6, below length limit, first", + "data": "100:100:100:100:100:100:255.255.255.255.255", + "valid": false + }, + { + "description": "a long invalid ipv6, below length limit, second", + "data": "100:100:100:100:100:100:100:255.255.255.255", + "valid": false } ] } diff --git a/json/tests/draft2019-09/optional/format/uri.json b/json/tests/draft2019-09/optional/format/uri.json index 25cc40c..4306a68 100644 --- a/json/tests/draft2019-09/optional/format/uri.json +++ b/json/tests/draft2019-09/optional/format/uri.json @@ -97,6 +97,11 @@ "description": "an invalid URI with spaces and missing scheme", "data": ":// should fail", "valid": false + }, + { + "description": "an invalid URI with comma in scheme", + "data": "bar,baz:foo", + "valid": false } ] } diff --git a/json/tests/draft2019-09/refRemote.json b/json/tests/draft2019-09/refRemote.json index 515263d..b9c6a28 100644 --- a/json/tests/draft2019-09/refRemote.json +++ b/json/tests/draft2019-09/refRemote.json @@ -54,7 +54,7 @@ "schema": { "$id": "http://localhost:1234/", "items": { - "$id": "folder/", + "$id": "baseUriChange/", "items": {"$ref": "folderInteger.json"} } }, @@ -76,10 +76,10 @@ "schema": { "$id": "http://localhost:1234/scope_change_defs1.json", "type" : "object", - "properties": {"list": {"$ref": "folder/"}}, + "properties": {"list": {"$ref": "baseUriChangeFolder/"}}, "$defs": { "baz": { - "$id": "folder/", + "$id": "baseUriChangeFolder/", "type": "array", "items": {"$ref": "folderInteger.json"} } @@ -103,10 +103,10 @@ "schema": { "$id": "http://localhost:1234/scope_change_defs2.json", "type" : "object", - "properties": {"list": {"$ref": "folder/#/$defs/bar"}}, + "properties": {"list": {"$ref": "baseUriChangeFolderInSubschema/#/$defs/bar"}}, "$defs": { "baz": { - "$id": "folder/", + "$id": "baseUriChangeFolderInSubschema/", "$defs": { "bar": { "type": "array", diff --git a/json/tests/draft2019-09/uniqueItems.json b/json/tests/draft2019-09/uniqueItems.json index fb1ddb5..4846c77 100644 --- a/json/tests/draft2019-09/uniqueItems.json +++ b/json/tests/draft2019-09/uniqueItems.json @@ -113,6 +113,16 @@ "description": "objects are non-unique despite key order", "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], "valid": false + }, + { + "description": "{\"a\": false} and {\"a\": 0} are unique", + "data": [{"a": false}, {"a": 0}], + "valid": true + }, + { + "description": "{\"a\": true} and {\"a\": 1} are unique", + "data": [{"a": true}, {"a": 1}], + "valid": true } ] }, diff --git a/json/tests/draft3/refRemote.json b/json/tests/draft3/refRemote.json index 4ca8047..de0cb43 100644 --- a/json/tests/draft3/refRemote.json +++ b/json/tests/draft3/refRemote.json @@ -54,7 +54,7 @@ "schema": { "id": "http://localhost:1234/", "items": { - "id": "folder/", + "id": "baseUriChange/", "items": {"$ref": "folderInteger.json"} } }, diff --git a/json/tests/draft3/uniqueItems.json b/json/tests/draft3/uniqueItems.json index 8f8dbdd..fd4b849 100644 --- a/json/tests/draft3/uniqueItems.json +++ b/json/tests/draft3/uniqueItems.json @@ -93,6 +93,16 @@ "description": "non-unique heterogeneous types are invalid", "data": [{}, [1], true, null, {}, 1], "valid": false + }, + { + "description": "{\"a\": false} and {\"a\": 0} are unique", + "data": [{"a": false}, {"a": 0}], + "valid": true + }, + { + "description": "{\"a\": true} and {\"a\": 1} are unique", + "data": [{"a": true}, {"a": 1}], + "valid": true } ] }, diff --git a/json/tests/draft4/optional/format/ipv6.json b/json/tests/draft4/optional/format/ipv6.json index 9b0881e..2a08cb4 100644 --- a/json/tests/draft4/optional/format/ipv6.json +++ b/json/tests/draft4/optional/format/ipv6.json @@ -112,6 +112,41 @@ "description": "ipv4 segment must have 4 octets", "data": "1:2:3:4:1.2.3", "valid": false + }, + { + "description": "leading whitespace is invalid", + "data": " ::1", + "valid": false + }, + { + "description": "trailing whitespace is invalid", + "data": "::1 ", + "valid": false + }, + { + "description": "netmask is not a part of ipv6 address", + "data": "fe80::/64", + "valid": false + }, + { + "description": "zone id is not a part of ipv6 address", + "data": "fe80::a%eth1", + "valid": false + }, + { + "description": "a long valid ipv6", + "data": "1000:1000:1000:1000:1000:1000:255.255.255.255", + "valid": true + }, + { + "description": "a long invalid ipv6, below length limit, first", + "data": "100:100:100:100:100:100:255.255.255.255.255", + "valid": false + }, + { + "description": "a long invalid ipv6, below length limit, second", + "data": "100:100:100:100:100:100:100:255.255.255.255", + "valid": false } ] } diff --git a/json/tests/draft4/optional/format/uri.json b/json/tests/draft4/optional/format/uri.json index 25cc40c..4306a68 100644 --- a/json/tests/draft4/optional/format/uri.json +++ b/json/tests/draft4/optional/format/uri.json @@ -97,6 +97,11 @@ "description": "an invalid URI with spaces and missing scheme", "data": ":// should fail", "valid": false + }, + { + "description": "an invalid URI with comma in scheme", + "data": "bar,baz:foo", + "valid": false } ] } diff --git a/json/tests/draft4/refRemote.json b/json/tests/draft4/refRemote.json index 8611fad..ce5e99a 100644 --- a/json/tests/draft4/refRemote.json +++ b/json/tests/draft4/refRemote.json @@ -54,7 +54,7 @@ "schema": { "id": "http://localhost:1234/", "items": { - "id": "folder/", + "id": "baseUriChange/", "items": {"$ref": "folderInteger.json"} } }, @@ -81,7 +81,7 @@ }, "definitions": { "baz": { - "id": "folder/", + "id": "baseUriChangeFolder/", "type": "array", "items": {"$ref": "folderInteger.json"} } @@ -110,7 +110,7 @@ }, "definitions": { "baz": { - "id": "folder/", + "id": "baseUriChangeFolderInSubschema/", "definitions": { "bar": { "type": "array", diff --git a/json/tests/draft4/uniqueItems.json b/json/tests/draft4/uniqueItems.json index fb1ddb5..4846c77 100644 --- a/json/tests/draft4/uniqueItems.json +++ b/json/tests/draft4/uniqueItems.json @@ -113,6 +113,16 @@ "description": "objects are non-unique despite key order", "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], "valid": false + }, + { + "description": "{\"a\": false} and {\"a\": 0} are unique", + "data": [{"a": false}, {"a": 0}], + "valid": true + }, + { + "description": "{\"a\": true} and {\"a\": 1} are unique", + "data": [{"a": true}, {"a": 1}], + "valid": true } ] }, diff --git a/json/tests/draft6/const.json b/json/tests/draft6/const.json index c53d04d..1c2cafc 100644 --- a/json/tests/draft6/const.json +++ b/json/tests/draft6/const.json @@ -126,6 +126,90 @@ ] }, { + "description": "const with [false] does not match [0]", + "schema": {"const": [false]}, + "tests": [ + { + "description": "[false] is valid", + "data": [false], + "valid": true + }, + { + "description": "[0] is invalid", + "data": [0], + "valid": false + }, + { + "description": "[0.0] is invalid", + "data": [0.0], + "valid": false + } + ] + }, + { + "description": "const with [true] does not match [1]", + "schema": {"const": [true]}, + "tests": [ + { + "description": "[true] is valid", + "data": [true], + "valid": true + }, + { + "description": "[1] is invalid", + "data": [1], + "valid": false + }, + { + "description": "[1.0] is invalid", + "data": [1.0], + "valid": false + } + ] + }, + { + "description": "const with {\"a\": false} does not match {\"a\": 0}", + "schema": {"const": {"a": false}}, + "tests": [ + { + "description": "{\"a\": false} is valid", + "data": {"a": false}, + "valid": true + }, + { + "description": "{\"a\": 0} is invalid", + "data": {"a": 0}, + "valid": false + }, + { + "description": "{\"a\": 0.0} is invalid", + "data": {"a": 0.0}, + "valid": false + } + ] + }, + { + "description": "const with {\"a\": true} does not match {\"a\": 1}", + "schema": {"const": {"a": true}}, + "tests": [ + { + "description": "{\"a\": true} is valid", + "data": {"a": true}, + "valid": true + }, + { + "description": "{\"a\": 1} is invalid", + "data": {"a": 1}, + "valid": false + }, + { + "description": "{\"a\": 1.0} is invalid", + "data": {"a": 1.0}, + "valid": false + } + ] + }, + { "description": "const with 0 does not match other zero-like types", "schema": {"const": 0}, "tests": [ diff --git a/json/tests/draft6/optional/format/ipv6.json b/json/tests/draft6/optional/format/ipv6.json index 9b0881e..2a08cb4 100644 --- a/json/tests/draft6/optional/format/ipv6.json +++ b/json/tests/draft6/optional/format/ipv6.json @@ -112,6 +112,41 @@ "description": "ipv4 segment must have 4 octets", "data": "1:2:3:4:1.2.3", "valid": false + }, + { + "description": "leading whitespace is invalid", + "data": " ::1", + "valid": false + }, + { + "description": "trailing whitespace is invalid", + "data": "::1 ", + "valid": false + }, + { + "description": "netmask is not a part of ipv6 address", + "data": "fe80::/64", + "valid": false + }, + { + "description": "zone id is not a part of ipv6 address", + "data": "fe80::a%eth1", + "valid": false + }, + { + "description": "a long valid ipv6", + "data": "1000:1000:1000:1000:1000:1000:255.255.255.255", + "valid": true + }, + { + "description": "a long invalid ipv6, below length limit, first", + "data": "100:100:100:100:100:100:255.255.255.255.255", + "valid": false + }, + { + "description": "a long invalid ipv6, below length limit, second", + "data": "100:100:100:100:100:100:100:255.255.255.255", + "valid": false } ] } diff --git a/json/tests/draft6/optional/format/uri.json b/json/tests/draft6/optional/format/uri.json index 25cc40c..4306a68 100644 --- a/json/tests/draft6/optional/format/uri.json +++ b/json/tests/draft6/optional/format/uri.json @@ -97,6 +97,11 @@ "description": "an invalid URI with spaces and missing scheme", "data": ":// should fail", "valid": false + }, + { + "description": "an invalid URI with comma in scheme", + "data": "bar,baz:foo", + "valid": false } ] } diff --git a/json/tests/draft6/refRemote.json b/json/tests/draft6/refRemote.json index 819d326..74a7862 100644 --- a/json/tests/draft6/refRemote.json +++ b/json/tests/draft6/refRemote.json @@ -54,7 +54,7 @@ "schema": { "$id": "http://localhost:1234/", "items": { - "$id": "folder/", + "$id": "baseUriChange/", "items": {"$ref": "folderInteger.json"} } }, @@ -81,7 +81,7 @@ }, "definitions": { "baz": { - "$id": "folder/", + "$id": "baseUriChangeFolder/", "type": "array", "items": {"$ref": "folderInteger.json"} } @@ -110,7 +110,7 @@ }, "definitions": { "baz": { - "$id": "folder/", + "$id": "baseUriChangeFolderInSubschema/", "definitions": { "bar": { "type": "array", diff --git a/json/tests/draft6/uniqueItems.json b/json/tests/draft6/uniqueItems.json index fb1ddb5..4846c77 100644 --- a/json/tests/draft6/uniqueItems.json +++ b/json/tests/draft6/uniqueItems.json @@ -113,6 +113,16 @@ "description": "objects are non-unique despite key order", "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], "valid": false + }, + { + "description": "{\"a\": false} and {\"a\": 0} are unique", + "data": [{"a": false}, {"a": 0}], + "valid": true + }, + { + "description": "{\"a\": true} and {\"a\": 1} are unique", + "data": [{"a": true}, {"a": 1}], + "valid": true } ] }, diff --git a/json/tests/draft7/const.json b/json/tests/draft7/const.json index c53d04d..1c2cafc 100644 --- a/json/tests/draft7/const.json +++ b/json/tests/draft7/const.json @@ -126,6 +126,90 @@ ] }, { + "description": "const with [false] does not match [0]", + "schema": {"const": [false]}, + "tests": [ + { + "description": "[false] is valid", + "data": [false], + "valid": true + }, + { + "description": "[0] is invalid", + "data": [0], + "valid": false + }, + { + "description": "[0.0] is invalid", + "data": [0.0], + "valid": false + } + ] + }, + { + "description": "const with [true] does not match [1]", + "schema": {"const": [true]}, + "tests": [ + { + "description": "[true] is valid", + "data": [true], + "valid": true + }, + { + "description": "[1] is invalid", + "data": [1], + "valid": false + }, + { + "description": "[1.0] is invalid", + "data": [1.0], + "valid": false + } + ] + }, + { + "description": "const with {\"a\": false} does not match {\"a\": 0}", + "schema": {"const": {"a": false}}, + "tests": [ + { + "description": "{\"a\": false} is valid", + "data": {"a": false}, + "valid": true + }, + { + "description": "{\"a\": 0} is invalid", + "data": {"a": 0}, + "valid": false + }, + { + "description": "{\"a\": 0.0} is invalid", + "data": {"a": 0.0}, + "valid": false + } + ] + }, + { + "description": "const with {\"a\": true} does not match {\"a\": 1}", + "schema": {"const": {"a": true}}, + "tests": [ + { + "description": "{\"a\": true} is valid", + "data": {"a": true}, + "valid": true + }, + { + "description": "{\"a\": 1} is invalid", + "data": {"a": 1}, + "valid": false + }, + { + "description": "{\"a\": 1.0} is invalid", + "data": {"a": 1.0}, + "valid": false + } + ] + }, + { "description": "const with 0 does not match other zero-like types", "schema": {"const": 0}, "tests": [ diff --git a/json/tests/draft7/optional/format/ipv6.json b/json/tests/draft7/optional/format/ipv6.json index 9b0881e..2a08cb4 100644 --- a/json/tests/draft7/optional/format/ipv6.json +++ b/json/tests/draft7/optional/format/ipv6.json @@ -112,6 +112,41 @@ "description": "ipv4 segment must have 4 octets", "data": "1:2:3:4:1.2.3", "valid": false + }, + { + "description": "leading whitespace is invalid", + "data": " ::1", + "valid": false + }, + { + "description": "trailing whitespace is invalid", + "data": "::1 ", + "valid": false + }, + { + "description": "netmask is not a part of ipv6 address", + "data": "fe80::/64", + "valid": false + }, + { + "description": "zone id is not a part of ipv6 address", + "data": "fe80::a%eth1", + "valid": false + }, + { + "description": "a long valid ipv6", + "data": "1000:1000:1000:1000:1000:1000:255.255.255.255", + "valid": true + }, + { + "description": "a long invalid ipv6, below length limit, first", + "data": "100:100:100:100:100:100:255.255.255.255.255", + "valid": false + }, + { + "description": "a long invalid ipv6, below length limit, second", + "data": "100:100:100:100:100:100:100:255.255.255.255", + "valid": false } ] } diff --git a/json/tests/draft7/optional/format/uri.json b/json/tests/draft7/optional/format/uri.json index 25cc40c..4306a68 100644 --- a/json/tests/draft7/optional/format/uri.json +++ b/json/tests/draft7/optional/format/uri.json @@ -97,6 +97,11 @@ "description": "an invalid URI with spaces and missing scheme", "data": ":// should fail", "valid": false + }, + { + "description": "an invalid URI with comma in scheme", + "data": "bar,baz:foo", + "valid": false } ] } diff --git a/json/tests/draft7/refRemote.json b/json/tests/draft7/refRemote.json index 819d326..74a7862 100644 --- a/json/tests/draft7/refRemote.json +++ b/json/tests/draft7/refRemote.json @@ -54,7 +54,7 @@ "schema": { "$id": "http://localhost:1234/", "items": { - "$id": "folder/", + "$id": "baseUriChange/", "items": {"$ref": "folderInteger.json"} } }, @@ -81,7 +81,7 @@ }, "definitions": { "baz": { - "$id": "folder/", + "$id": "baseUriChangeFolder/", "type": "array", "items": {"$ref": "folderInteger.json"} } @@ -110,7 +110,7 @@ }, "definitions": { "baz": { - "$id": "folder/", + "$id": "baseUriChangeFolderInSubschema/", "definitions": { "bar": { "type": "array", diff --git a/json/tests/draft7/uniqueItems.json b/json/tests/draft7/uniqueItems.json index fb1ddb5..4846c77 100644 --- a/json/tests/draft7/uniqueItems.json +++ b/json/tests/draft7/uniqueItems.json @@ -113,6 +113,16 @@ "description": "objects are non-unique despite key order", "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], "valid": false + }, + { + "description": "{\"a\": false} and {\"a\": 0} are unique", + "data": [{"a": false}, {"a": 0}], + "valid": true + }, + { + "description": "{\"a\": true} and {\"a\": 1} are unique", + "data": [{"a": true}, {"a": 1}], + "valid": true } ] }, |