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/draft-future/anchor.json | |
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/draft-future/anchor.json')
-rw-r--r-- | json/tests/draft-future/anchor.json | 138 |
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 + } + ] + } +] |