xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft2020-12/refRemote.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2    {
3        "description": "remote ref",
4        "schema": {
5            "$schema": "https://json-schema.org/draft/2020-12/schema",
6            "$ref": "http://localhost:1234/draft2020-12/integer.json"
7        },
8        "tests": [
9            {
10                "description": "remote ref valid",
11                "data": 1,
12                "valid": true
13            },
14            {
15                "description": "remote ref invalid",
16                "data": "a",
17                "valid": false
18            }
19        ]
20    },
21    {
22        "description": "fragment within remote ref",
23        "schema": {
24            "$schema": "https://json-schema.org/draft/2020-12/schema",
25            "$ref": "http://localhost:1234/draft2020-12/subSchemas.json#/$defs/integer"
26        },
27        "tests": [
28            {
29                "description": "remote fragment valid",
30                "data": 1,
31                "valid": true
32            },
33            {
34                "description": "remote fragment invalid",
35                "data": "a",
36                "valid": false
37            }
38        ]
39    },
40    {
41        "description": "anchor within remote ref",
42        "schema": {
43            "$schema": "https://json-schema.org/draft/2020-12/schema",
44            "$ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#foo"
45        },
46        "tests": [
47            {
48                "description": "remote anchor valid",
49                "data": 1,
50                "valid": true
51            },
52            {
53                "description": "remote anchor invalid",
54                "data": "a",
55                "valid": false
56            }
57        ]
58    },
59    {
60        "description": "ref within remote ref",
61        "schema": {
62            "$schema": "https://json-schema.org/draft/2020-12/schema",
63            "$ref": "http://localhost:1234/draft2020-12/subSchemas.json#/$defs/refToInteger"
64        },
65        "tests": [
66            {
67                "description": "ref within ref valid",
68                "data": 1,
69                "valid": true
70            },
71            {
72                "description": "ref within ref invalid",
73                "data": "a",
74                "valid": false
75            }
76        ]
77    },
78    {
79        "description": "base URI change",
80        "schema": {
81            "$schema": "https://json-schema.org/draft/2020-12/schema",
82            "$id": "http://localhost:1234/draft2020-12/",
83            "items": {
84                "$id": "baseUriChange/",
85                "items": {"$ref": "folderInteger.json"}
86            }
87        },
88        "tests": [
89            {
90                "description": "base URI change ref valid",
91                "data": [[1]],
92                "valid": true
93            },
94            {
95                "description": "base URI change ref invalid",
96                "data": [["a"]],
97                "valid": false
98            }
99        ]
100    },
101    {
102        "description": "base URI change - change folder",
103        "schema": {
104            "$schema": "https://json-schema.org/draft/2020-12/schema",
105            "$id": "http://localhost:1234/draft2020-12/scope_change_defs1.json",
106            "type" : "object",
107            "properties": {"list": {"$ref": "baseUriChangeFolder/"}},
108            "$defs": {
109                "baz": {
110                    "$id": "baseUriChangeFolder/",
111                    "type": "array",
112                    "items": {"$ref": "folderInteger.json"}
113                }
114            }
115        },
116        "tests": [
117            {
118                "description": "number is valid",
119                "data": {"list": [1]},
120                "valid": true
121            },
122            {
123                "description": "string is invalid",
124                "data": {"list": ["a"]},
125                "valid": false
126            }
127        ]
128    },
129    {
130        "description": "base URI change - change folder in subschema",
131        "schema": {
132            "$schema": "https://json-schema.org/draft/2020-12/schema",
133            "$id": "http://localhost:1234/draft2020-12/scope_change_defs2.json",
134            "type" : "object",
135            "properties": {"list": {"$ref": "baseUriChangeFolderInSubschema/#/$defs/bar"}},
136            "$defs": {
137                "baz": {
138                    "$id": "baseUriChangeFolderInSubschema/",
139                    "$defs": {
140                        "bar": {
141                            "type": "array",
142                            "items": {"$ref": "folderInteger.json"}
143                        }
144                    }
145                }
146            }
147        },
148        "tests": [
149            {
150                "description": "number is valid",
151                "data": {"list": [1]},
152                "valid": true
153            },
154            {
155                "description": "string is invalid",
156                "data": {"list": ["a"]},
157                "valid": false
158            }
159        ]
160    },
161    {
162        "description": "root ref in remote ref",
163        "schema": {
164            "$schema": "https://json-schema.org/draft/2020-12/schema",
165            "$id": "http://localhost:1234/draft2020-12/object",
166            "type": "object",
167            "properties": {
168                "name": {"$ref": "name-defs.json#/$defs/orNull"}
169            }
170        },
171        "tests": [
172            {
173                "description": "string is valid",
174                "data": {
175                    "name": "foo"
176                },
177                "valid": true
178            },
179            {
180                "description": "null is valid",
181                "data": {
182                    "name": null
183                },
184                "valid": true
185            },
186            {
187                "description": "object is invalid",
188                "data": {
189                    "name": {
190                        "name": null
191                    }
192                },
193                "valid": false
194            }
195        ]
196    },
197    {
198        "description": "remote ref with ref to defs",
199        "schema": {
200            "$schema": "https://json-schema.org/draft/2020-12/schema",
201            "$id": "http://localhost:1234/draft2020-12/schema-remote-ref-ref-defs1.json",
202            "$ref": "ref-and-defs.json"
203        },
204        "tests": [
205            {
206                "description": "invalid",
207                "data": {
208                    "bar": 1
209                },
210                "valid": false
211            },
212            {
213                "description": "valid",
214                "data": {
215                    "bar": "a"
216                },
217                "valid": true
218            }
219        ]
220    },
221    {
222        "description": "Location-independent identifier in remote ref",
223        "schema": {
224            "$schema": "https://json-schema.org/draft/2020-12/schema",
225            "$ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#/$defs/refToInteger"
226        },
227        "tests": [
228            {
229                "description": "integer is valid",
230                "data": 1,
231                "valid": true
232            },
233            {
234                "description": "string is invalid",
235                "data": "foo",
236                "valid": false
237            }
238        ]
239    },
240    {
241        "description": "retrieved nested refs resolve relative to their URI not $id",
242        "schema": {
243            "$schema": "https://json-schema.org/draft/2020-12/schema",
244            "$id": "http://localhost:1234/draft2020-12/some-id",
245            "properties": {
246                "name": {"$ref": "nested/foo-ref-string.json"}
247            }
248        },
249        "tests": [
250            {
251                "description": "number is invalid",
252                "data": {
253                    "name": {"foo":  1}
254                },
255                "valid": false
256            },
257            {
258                "description": "string is valid",
259                "data": {
260                    "name": {"foo":  "a"}
261                },
262                "valid": true
263            }
264        ]
265    },
266    {
267        "description": "remote HTTP ref with different $id",
268        "schema": {
269            "$schema": "https://json-schema.org/draft/2020-12/schema",
270            "$ref": "http://localhost:1234/different-id-ref-string.json"
271        },
272        "tests": [
273            {
274                "description": "number is invalid",
275                "data": 1,
276                "valid": false
277            },
278            {
279                "description": "string is valid",
280                "data": "foo",
281                "valid": true
282            }
283        ]
284    },
285    {
286        "description": "remote HTTP ref with different URN $id",
287        "schema": {
288            "$schema": "https://json-schema.org/draft/2020-12/schema",
289            "$ref": "http://localhost:1234/urn-ref-string.json"
290        },
291        "tests": [
292            {
293                "description": "number is invalid",
294                "data": 1,
295                "valid": false
296            },
297            {
298                "description": "string is valid",
299                "data": "foo",
300                "valid": true
301            }
302        ]
303    },
304    {
305        "description": "remote HTTP ref with nested absolute ref",
306        "schema": {
307            "$schema": "https://json-schema.org/draft/2020-12/schema",
308            "$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"
309        },
310        "tests": [
311            {
312                "description": "number is invalid",
313                "data": 1,
314                "valid": false
315            },
316            {
317                "description": "string is valid",
318                "data": "foo",
319                "valid": true
320            }
321        ]
322    },
323    {
324        "description": "$ref to $ref finds detached $anchor",
325        "schema": {
326            "$schema": "https://json-schema.org/draft/2020-12/schema",
327            "$ref": "http://localhost:1234/draft2020-12/detached-ref.json#/$defs/foo"
328        },
329        "tests": [
330            {
331                "description": "number is valid",
332                "data": 1,
333                "valid": true
334            },
335            {
336                "description": "non-number is invalid",
337                "data": "a",
338                "valid": false
339            }
340        ]
341    }
342]
343