summaryrefslogtreecommitdiff
path: root/json/tests/draft-future/anchor.json
diff options
context:
space:
mode:
Diffstat (limited to 'json/tests/draft-future/anchor.json')
-rw-r--r--json/tests/draft-future/anchor.json138
1 files changed, 138 insertions, 0 deletions
diff --git a/json/tests/draft-future/anchor.json b/json/tests/draft-future/anchor.json
new file mode 100644
index 0000000..045cdc3
--- /dev/null
+++ b/json/tests/draft-future/anchor.json
@@ -0,0 +1,138 @@
+[
+ {
+ "description": "Location-independent identifier",
+ "schema": {
+ "$ref": "#foo",
+ "$defs": {
+ "A": {
+ "$anchor": "foo",
+ "type": "integer"
+ }
+ }
+ },
+ "tests": [
+ {
+ "data": 1,
+ "description": "match",
+ "valid": true
+ },
+ {
+ "data": "a",
+ "description": "mismatch",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "Location-independent identifier with absolute URI",
+ "schema": {
+ "$ref": "http://localhost:1234/bar#foo",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/bar",
+ "$anchor": "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",
+ "$ref": "http://localhost:1234/nested.json#foo",
+ "$defs": {
+ "A": {
+ "$id": "nested.json",
+ "$defs": {
+ "B": {
+ "$anchor": "foo",
+ "type": "integer"
+ }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "data": 1,
+ "description": "match",
+ "valid": true
+ },
+ {
+ "data": "a",
+ "description": "mismatch",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "$anchor inside an enum is not a real identifier",
+ "comment": "the implementation must not be confused by an $anchor buried in the enum",
+ "schema": {
+ "$defs": {
+ "anchor_in_enum": {
+ "enum": [
+ {
+ "$anchor": "my_anchor",
+ "type": "null"
+ }
+ ]
+ },
+ "real_identifier_in_schema": {
+ "$anchor": "my_anchor",
+ "type": "string"
+ },
+ "zzz_anchor_in_const": {
+ "const": {
+ "$anchor": "my_anchor",
+ "type": "null"
+ }
+ }
+ },
+ "anyOf": [
+ { "$ref": "#/$defs/anchor_in_enum" },
+ { "$ref": "#my_anchor" }
+ ]
+ },
+ "tests": [
+ {
+ "description": "exact match to enum, and type matches",
+ "data": {
+ "$anchor": "my_anchor",
+ "type": "null"
+ },
+ "valid": true
+ },
+ {
+ "description": "in implementations that strip $anchor, this may match either $def",
+ "data": {
+ "type": "null"
+ },
+ "valid": false
+ },
+ {
+ "description": "match $ref to $anchor",
+ "data": "a string to match #/$defs/anchor_in_enum",
+ "valid": true
+ },
+ {
+ "description": "no match on enum or $ref to $anchor",
+ "data": 1,
+ "valid": false
+ }
+ ]
+ }
+]