diff options
author | Julian Berman <Julian@GrayVines.com> | 2021-06-24 11:18:28 +0200 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2021-06-24 11:18:28 +0200 |
commit | 3f4ed46e7169ad667c16df73268edb31587f6b01 (patch) | |
tree | 60048c975048f1af17253596ad95081933c1ac95 /json/tests/draft6 | |
parent | 23e210c063e3a35b8e30ec9bc8baade4924267b3 (diff) | |
parent | 6d455c83e3fd953a9e762e596c52ce1fc4bf8740 (diff) | |
download | jsonschema-3f4ed46e7169ad667c16df73268edb31587f6b01.tar.gz |
Merge commit '6d455c83e3fd953a9e762e596c52ce1fc4bf8740'
* commit '6d455c83e3fd953a9e762e596c52ce1fc4bf8740':
Squashed 'json/' changes from 09fd353f..0aefbb3d
Diffstat (limited to 'json/tests/draft6')
-rw-r--r-- | json/tests/draft6/contains.json | 21 | ||||
-rw-r--r-- | json/tests/draft6/id.json | 10 | ||||
-rw-r--r-- | json/tests/draft6/propertyNames.json | 29 | ||||
-rw-r--r-- | json/tests/draft6/ref.json | 130 | ||||
-rw-r--r-- | json/tests/draft6/refRemote.json | 23 | ||||
-rw-r--r-- | json/tests/draft6/unknownKeyword.json | 56 |
6 files changed, 238 insertions, 31 deletions
diff --git a/json/tests/draft6/contains.json b/json/tests/draft6/contains.json index c5471cc..215da98 100644 --- a/json/tests/draft6/contains.json +++ b/json/tests/draft6/contains.json @@ -125,5 +125,26 @@ "valid": false } ] + }, + { + "description": "contains with false if subschema", + "schema": { + "contains": { + "if": false, + "else": true + } + }, + "tests": [ + { + "description": "any non-empty array is valid", + "data": ["foo"], + "valid": true + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + } + ] } ] diff --git a/json/tests/draft6/id.json b/json/tests/draft6/id.json index d276001..b58e0d0 100644 --- a/json/tests/draft6/id.json +++ b/json/tests/draft6/id.json @@ -7,32 +7,32 @@ "id_in_enum": { "enum": [ { - "$id": "https://localhost:1234/my_identifier.json", + "$id": "https://localhost:1234/id/my_identifier.json", "type": "null" } ] }, "real_id_in_schema": { - "$id": "https://localhost:1234/my_identifier.json", + "$id": "https://localhost:1234/id/my_identifier.json", "type": "string" }, "zzz_id_in_const": { "const": { - "$id": "https://localhost:1234/my_identifier.json", + "$id": "https://localhost:1234/id/my_identifier.json", "type": "null" } } }, "anyOf": [ { "$ref": "#/definitions/id_in_enum" }, - { "$ref": "https://localhost:1234/my_identifier.json" } + { "$ref": "https://localhost:1234/id/my_identifier.json" } ] }, "tests": [ { "description": "exact match to enum, and type matches", "data": { - "$id": "https://localhost:1234/my_identifier.json", + "$id": "https://localhost:1234/id/my_identifier.json", "type": "null" }, "valid": true diff --git a/json/tests/draft6/propertyNames.json b/json/tests/draft6/propertyNames.json index 8423690..f0788e6 100644 --- a/json/tests/draft6/propertyNames.json +++ b/json/tests/draft6/propertyNames.json @@ -44,6 +44,35 @@ ] }, { + "description": "propertyNames validation with pattern", + "schema": { + "propertyNames": { "pattern": "^a+$" } + }, + "tests": [ + { + "description": "matching property names valid", + "data": { + "a": {}, + "aa": {}, + "aaa": {} + }, + "valid": true + }, + { + "description": "non-matching property name is invalid", + "data": { + "aaA": {} + }, + "valid": false + }, + { + "description": "object without properties is valid", + "data": {}, + "valid": true + } + ] + }, + { "description": "propertyNames with boolean schema true", "schema": {"propertyNames": true}, "tests": [ diff --git a/json/tests/draft6/ref.json b/json/tests/draft6/ref.json index 0357f3e..1fb426b 100644 --- a/json/tests/draft6/ref.json +++ b/json/tests/draft6/ref.json @@ -410,32 +410,6 @@ ] }, { - "description": "Location-independent identifier with absolute URI", - "schema": { - "allOf": [{ - "$ref": "http://localhost:1234/bar#foo" - }], - "definitions": { - "A": { - "$id": "http://localhost:1234/bar#foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { "description": "Location-independent identifier with base URI change in subschema", "schema": { "$id": "http://localhost:1234/root", @@ -494,5 +468,109 @@ "valid": true } ] + }, + { + "description": "refs with relative uris and defs", + "schema": { + "$id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "$id": "schema-relative-uri-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { "type": "string" } + } + } + }, + "allOf": [ { "$ref": "#/definitions/inner" } ] + } + }, + "allOf": [ { "$ref": "schema-relative-uri-defs2.json" } ] + }, + "tests": [ + { + "description": "invalid on inner field", + "data": { + "foo": { + "bar": 1 + }, + "bar": "a" + }, + "valid": false + }, + { + "description": "invalid on outer field", + "data": { + "foo": { + "bar": "a" + }, + "bar": 1 + }, + "valid": false + }, + { + "description": "valid on both fields", + "data": { + "foo": { + "bar": "a" + }, + "bar": "a" + }, + "valid": true + } + ] + }, + { + "description": "relative refs with absolute uris and defs", + "schema": { + "$id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "$id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { "type": "string" } + } + } + }, + "allOf": [ { "$ref": "#/definitions/inner" } ] + } + }, + "allOf": [ { "$ref": "schema-refs-absolute-uris-defs2.json" } ] + }, + "tests": [ + { + "description": "invalid on inner field", + "data": { + "foo": { + "bar": 1 + }, + "bar": "a" + }, + "valid": false + }, + { + "description": "invalid on outer field", + "data": { + "foo": { + "bar": "a" + }, + "bar": 1 + }, + "valid": false + }, + { + "description": "valid on both fields", + "data": { + "foo": { + "bar": "a" + }, + "bar": "a" + }, + "valid": true + } + ] } ] diff --git a/json/tests/draft6/refRemote.json b/json/tests/draft6/refRemote.json index 74a7862..9d8057b 100644 --- a/json/tests/draft6/refRemote.json +++ b/json/tests/draft6/refRemote.json @@ -167,5 +167,28 @@ "valid": false } ] + }, + { + "description": "remote ref with ref to definitions", + "schema": { + "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", + "$ref": "ref-and-definitions.json" + }, + "tests": [ + { + "description": "invalid", + "data": { + "bar": 1 + }, + "valid": false + }, + { + "description": "valid", + "data": { + "bar": "a" + }, + "valid": true + } + ] } ] diff --git a/json/tests/draft6/unknownKeyword.json b/json/tests/draft6/unknownKeyword.json new file mode 100644 index 0000000..1f58d97 --- /dev/null +++ b/json/tests/draft6/unknownKeyword.json @@ -0,0 +1,56 @@ +[ + { + "description": "$id inside an unknown keyword is not a real identifier", + "comment": "the implementation must not be confused by an $id in locations we do not know how to parse", + "schema": { + "definitions": { + "id_in_unknown0": { + "not": { + "array_of_schemas": [ + { + "$id": "https://localhost:1234/unknownKeyword/my_identifier.json", + "type": "null" + } + ] + } + }, + "real_id_in_schema": { + "$id": "https://localhost:1234/unknownKeyword/my_identifier.json", + "type": "string" + }, + "id_in_unknown1": { + "not": { + "object_of_schemas": { + "foo": { + "$id": "https://localhost:1234/unknownKeyword/my_identifier.json", + "type": "integer" + } + } + } + } + }, + "anyOf": [ + { "$ref": "#/definitions/id_in_unknown0" }, + { "$ref": "#/definitions/id_in_unknown1" }, + { "$ref": "https://localhost:1234/unknownKeyword/my_identifier.json" } + ] + }, + "tests": [ + { + "description": "type matches second anyOf, which has a real schema in it", + "data": "a string", + "valid": true + }, + { + "description": "type matches non-schema in first anyOf", + "data": null, + "valid": false + }, + { + "description": "type matches non-schema in third anyOf", + "data": 1, + "valid": false + } + ] + } +] |