Debian Codegraph @

spec/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json

raw ◀ ▶
1 Debian patch touch this file
•1 [
2 {
3 "description": "Location-independent identifier",
4 "schema": {
5 "$ref": "#foo",
6 "$defs": {
7 "A": {
8 "$anchor": "foo",
9 "type": "integer"
10 }
11 }
12 },
13 "tests": [
14 {
15 "data": 1,
16 "description": "match",
17 "valid": true
18 },
19 {
20 "data": "a",
21 "description": "mismatch",
22 "valid": false
23 }
24 ]
25 },
26 {
27 "description": "Location-independent identifier with absolute URI",
28 "schema": {
29 "$ref": "http://localhost:1234/bar#foo",
30 "$defs": {
31 "A": {
32 "$id": "http://localhost:1234/bar",
33 "$anchor": "foo",
34 "type": "integer"
35 }
36 }
37 },
38 "tests": [
39 {
40 "data": 1,
41 "description": "match",
42 "valid": true
43 },
44 {
45 "data": "a",
46 "description": "mismatch",
47 "valid": false
48 }
49 ]
50 },
51 {
52 "description": "Location-independent identifier with base URI change in subschema",
53 "schema": {
54 "$id": "http://localhost:1234/root",
55 "$ref": "http://localhost:1234/nested.json#foo",
56 "$defs": {
57 "A": {
58 "$id": "nested.json",
59 "$defs": {
60 "B": {
61 "$anchor": "foo",
62 "type": "integer"
63 }
64 }
65 }
66 }
67 },
68 "tests": [
69 {
70 "data": 1,
71 "description": "match",
72 "valid": true
73 },
74 {
75 "data": "a",
76 "description": "mismatch",
77 "valid": false
78 }
79 ]
80 },
81 {
82 "description": "$anchor inside an enum is not a real identifier",
83 "comment": "the implementation must not be confused by an $anchor buried in the enum",
84 "schema": {
85 "$defs": {
86 "anchor_in_enum": {
87 "enum": [
88 {
89 "$anchor": "my_anchor",
90 "type": "null"
91 }
92 ]
93 },
94 "real_identifier_in_schema": {
95 "$anchor": "my_anchor",
96 "type": "string"
97 },
98 "zzz_anchor_in_const": {
99 "const": {
100 "$anchor": "my_anchor",
101 "type": "null"
102 }
103 }
104 },
105 "anyOf": [
106 { "$ref": "#/$defs/anchor_in_enum" },
107 { "$ref": "#my_anchor" }
108 ]
109 },
110 "tests": [
111 {
112 "description": "exact match to enum, and type matches",
113 "data": {
114 "$anchor": "my_anchor",
115 "type": "null"
116 },
117 "valid": true
118 },
119 {
120 "description": "in implementations that strip $anchor, this may match either $def",
121 "data": {
122 "type": "null"
123 },
124 "valid": false
125 },
126 {
127 "description": "match $ref to $anchor",
128 "data": "a string to match #/$defs/anchor_in_enum",
129 "valid": true
130 },
131 {
132 "description": "no match on enum or $ref to $anchor",
133 "data": 1,
134 "valid": false
135 }
136 ]
137 },
138 {
139 "description": "same $anchor with different base uri",
140 "schema": {
141 "$id": "http://localhost:1234/foobar",
142 "$defs": {
143 "A": {
144 "$id": "child1",
145 "allOf": [
146 {
147 "$id": "child2",
148 "$anchor": "my_anchor",
149 "type": "number"
150 },
151 {
152 "$anchor": "my_anchor",
153 "type": "string"
154 }
155 ]
156 }
157 },
158 "$ref": "child1#my_anchor"
159 },
160 "tests": [
161 {
162 "description": "$ref should resolve to /$defs/A/allOf/1",
163 "data": "a",
164 "valid": true
165 },
166 {
167 "description": "$ref should not resolve to /$defs/A/allOf/0",
168 "data": 1,
169 "valid": false
170 }
171 ]
172 }
173 ]