diff options
author | Julian Berman <Julian@GrayVines.com> | 2021-06-26 08:44:14 +0200 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2021-06-26 08:44:14 +0200 |
commit | 4e76fb6ae3c1f77d12bca82e4f92691dd57cac15 (patch) | |
tree | 7b0662b091ff7f62f99e6dee78fafe12db2dec98 | |
parent | 6d455c83e3fd953a9e762e596c52ce1fc4bf8740 (diff) | |
download | jsonschema-4e76fb6ae3c1f77d12bca82e4f92691dd57cac15.tar.gz |
Squashed 'json/' changes from 0aefbb3d..1326f36e
1326f36e Merge pull request #493 from json-schema-org/ether/id-sibling-to-ref
b9bddc9c test that sibling $ids to $refs are ignored
2f6a498d Merge pull request #492 from json-schema-org/ether/fix-refRemote
61d03c0e fix buggy test with $ref in older drafts
git-subtree-dir: json
git-subtree-split: 1326f36ebb30f81162f0e69ae8e7079c29bcd880
-rw-r--r-- | tests/draft3/ref.json | 36 | ||||
-rw-r--r-- | tests/draft4/ref.json | 36 | ||||
-rw-r--r-- | tests/draft6/ref.json | 36 | ||||
-rw-r--r-- | tests/draft6/refRemote.json | 4 | ||||
-rw-r--r-- | tests/draft7/ref.json | 36 | ||||
-rw-r--r-- | tests/draft7/refRemote.json | 4 |
6 files changed, 150 insertions, 2 deletions
diff --git a/tests/draft3/ref.json b/tests/draft3/ref.json index 26dcb52..760b771 100644 --- a/tests/draft3/ref.json +++ b/tests/draft3/ref.json @@ -201,6 +201,42 @@ ] }, { + "description": "$ref prevents a sibling $id from changing the base uri", + "schema": { + "$id": "http://localhost:1234/sibling_id/base/", + "definitions": { + "foo": { + "$id": "http://localhost:1234/sibling_id/foo.json", + "minimum": 2 + }, + "base_foo": { + "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", + "$id": "foo.json", + "minimum": 5 + } + }, + "allOf": [ + { + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$id": "http://localhost:1234/sibling_id/", + "$ref": "foo.json" + } + ] + }, + "tests": [ + { + "description": "$ref resolves to /definitions/foo, data validates", + "data": 10, + "valid": true + }, + { + "description": "$ref resolves to /definitions/foo, data does not validate", + "data": 1, + "valid": false + } + ] + }, + { "description": "remote ref, containing refs itself", "schema": {"$ref": "http://json-schema.org/draft-03/schema#"}, "tests": [ diff --git a/tests/draft4/ref.json b/tests/draft4/ref.json index cc2ecf1..ae3770b 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -176,6 +176,42 @@ ] }, { + "description": "$ref prevents a sibling $id from changing the base uri", + "schema": { + "$id": "http://localhost:1234/sibling_id/base/", + "definitions": { + "foo": { + "$id": "http://localhost:1234/sibling_id/foo.json", + "minimum": 2 + }, + "base_foo": { + "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", + "$id": "foo.json", + "minimum": 5 + } + }, + "allOf": [ + { + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$id": "http://localhost:1234/sibling_id/", + "$ref": "foo.json" + } + ] + }, + "tests": [ + { + "description": "$ref resolves to /definitions/foo, data validates", + "data": 10, + "valid": true + }, + { + "description": "$ref resolves to /definitions/foo, data does not validate", + "data": 1, + "valid": false + } + ] + }, + { "description": "remote ref, containing refs itself", "schema": {"$ref": "http://json-schema.org/draft-04/schema#"}, "tests": [ diff --git a/tests/draft6/ref.json b/tests/draft6/ref.json index 1fb426b..7780c3f 100644 --- a/tests/draft6/ref.json +++ b/tests/draft6/ref.json @@ -176,6 +176,42 @@ ] }, { + "description": "$ref prevents a sibling $id from changing the base uri", + "schema": { + "$id": "http://localhost:1234/sibling_id/base/", + "definitions": { + "foo": { + "$id": "http://localhost:1234/sibling_id/foo.json", + "minimum": 2 + }, + "base_foo": { + "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", + "$id": "foo.json", + "minimum": 5 + } + }, + "allOf": [ + { + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$id": "http://localhost:1234/sibling_id/", + "$ref": "foo.json" + } + ] + }, + "tests": [ + { + "description": "$ref resolves to /definitions/foo, data validates", + "data": 10, + "valid": true + }, + { + "description": "$ref resolves to /definitions/foo, data does not validate", + "data": 1, + "valid": false + } + ] + }, + { "description": "remote ref, containing refs itself", "schema": {"$ref": "http://json-schema.org/draft-06/schema#"}, "tests": [ diff --git a/tests/draft6/refRemote.json b/tests/draft6/refRemote.json index 9d8057b..a2221b2 100644 --- a/tests/draft6/refRemote.json +++ b/tests/draft6/refRemote.json @@ -172,7 +172,9 @@ "description": "remote ref with ref to definitions", "schema": { "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", - "$ref": "ref-and-definitions.json" + "allOf": [ + { "$ref": "ref-and-definitions.json" } + ] }, "tests": [ { diff --git a/tests/draft7/ref.json b/tests/draft7/ref.json index 406ae16..ff98d79 100644 --- a/tests/draft7/ref.json +++ b/tests/draft7/ref.json @@ -176,6 +176,42 @@ ] }, { + "description": "$ref prevents a sibling $id from changing the base uri", + "schema": { + "$id": "http://localhost:1234/sibling_id/base/", + "definitions": { + "foo": { + "$id": "http://localhost:1234/sibling_id/foo.json", + "minimum": 2 + }, + "base_foo": { + "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", + "$id": "foo.json", + "minimum": 5 + } + }, + "allOf": [ + { + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$id": "http://localhost:1234/sibling_id/", + "$ref": "foo.json" + } + ] + }, + "tests": [ + { + "description": "$ref resolves to /definitions/foo, data validates", + "data": 10, + "valid": true + }, + { + "description": "$ref resolves to /definitions/foo, data does not validate", + "data": 1, + "valid": false + } + ] + }, + { "description": "remote ref, containing refs itself", "schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, "tests": [ diff --git a/tests/draft7/refRemote.json b/tests/draft7/refRemote.json index 9d8057b..a2221b2 100644 --- a/tests/draft7/refRemote.json +++ b/tests/draft7/refRemote.json @@ -172,7 +172,9 @@ "description": "remote ref with ref to definitions", "schema": { "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", - "$ref": "ref-and-definitions.json" + "allOf": [ + { "$ref": "ref-and-definitions.json" } + ] }, "tests": [ { |