xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft2020-12/ref.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2    {
3        "description": "root pointer ref",
4        "schema": {
5            "$schema": "https://json-schema.org/draft/2020-12/schema",
6            "properties": {
7                "foo": {"$ref": "#"}
8            },
9            "additionalProperties": false
10        },
11        "tests": [
12            {
13                "description": "match",
14                "data": {"foo": false},
15                "valid": true
16            },
17            {
18                "description": "recursive match",
19                "data": {"foo": {"foo": false}},
20                "valid": true
21            },
22            {
23                "description": "mismatch",
24                "data": {"bar": false},
25                "valid": false
26            },
27            {
28                "description": "recursive mismatch",
29                "data": {"foo": {"bar": false}},
30                "valid": false
31            }
32        ]
33    },
34    {
35        "description": "relative pointer ref to object",
36        "schema": {
37            "$schema": "https://json-schema.org/draft/2020-12/schema",
38            "properties": {
39                "foo": {"type": "integer"},
40                "bar": {"$ref": "#/properties/foo"}
41            }
42        },
43        "tests": [
44            {
45                "description": "match",
46                "data": {"bar": 3},
47                "valid": true
48            },
49            {
50                "description": "mismatch",
51                "data": {"bar": true},
52                "valid": false
53            }
54        ]
55    },
56    {
57        "description": "relative pointer ref to array",
58        "schema": {
59            "$schema": "https://json-schema.org/draft/2020-12/schema",
60            "prefixItems": [
61                {"type": "integer"},
62                {"$ref": "#/prefixItems/0"}
63            ]
64        },
65        "tests": [
66            {
67                "description": "match array",
68                "data": [1, 2],
69                "valid": true
70            },
71            {
72                "description": "mismatch array",
73                "data": [1, "foo"],
74                "valid": false
75            }
76        ]
77    },
78    {
79        "description": "escaped pointer ref",
80        "schema": {
81            "$schema": "https://json-schema.org/draft/2020-12/schema",
82            "$defs": {
83                "tilde~field": {"type": "integer"},
84                "slash/field": {"type": "integer"},
85                "percent%field": {"type": "integer"}
86            },
87            "properties": {
88                "tilde": {"$ref": "#/$defs/tilde~0field"},
89                "slash": {"$ref": "#/$defs/slash~1field"},
90                "percent": {"$ref": "#/$defs/percent%25field"}
91            }
92        },
93        "tests": [
94            {
95                "description": "slash invalid",
96                "data": {"slash": "aoeu"},
97                "valid": false
98            },
99            {
100                "description": "tilde invalid",
101                "data": {"tilde": "aoeu"},
102                "valid": false
103            },
104            {
105                "description": "percent invalid",
106                "data": {"percent": "aoeu"},
107                "valid": false
108            },
109            {
110                "description": "slash valid",
111                "data": {"slash": 123},
112                "valid": true
113            },
114            {
115                "description": "tilde valid",
116                "data": {"tilde": 123},
117                "valid": true
118            },
119            {
120                "description": "percent valid",
121                "data": {"percent": 123},
122                "valid": true
123            }
124        ]
125    },
126    {
127        "description": "nested refs",
128        "schema": {
129            "$schema": "https://json-schema.org/draft/2020-12/schema",
130            "$defs": {
131                "a": {"type": "integer"},
132                "b": {"$ref": "#/$defs/a"},
133                "c": {"$ref": "#/$defs/b"}
134            },
135            "$ref": "#/$defs/c"
136        },
137        "tests": [
138            {
139                "description": "nested ref valid",
140                "data": 5,
141                "valid": true
142            },
143            {
144                "description": "nested ref invalid",
145                "data": "a",
146                "valid": false
147            }
148        ]
149    },
150    {
151        "description": "ref applies alongside sibling keywords",
152        "schema": {
153            "$schema": "https://json-schema.org/draft/2020-12/schema",
154            "$defs": {
155                "reffed": {
156                    "type": "array"
157                }
158            },
159            "properties": {
160                "foo": {
161                    "$ref": "#/$defs/reffed",
162                    "maxItems": 2
163                }
164            }
165        },
166        "tests": [
167            {
168                "description": "ref valid, maxItems valid",
169                "data": { "foo": [] },
170                "valid": true
171            },
172            {
173                "description": "ref valid, maxItems invalid",
174                "data": { "foo": [1, 2, 3] },
175                "valid": false
176            },
177            {
178                "description": "ref invalid",
179                "data": { "foo": "string" },
180                "valid": false
181            }
182        ]
183    },
184    {
185        "description": "remote ref, containing refs itself",
186        "schema": {
187            "$schema": "https://json-schema.org/draft/2020-12/schema",
188            "$ref": "https://json-schema.org/draft/2020-12/schema"
189        },
190        "tests": [
191            {
192                "description": "remote ref valid",
193                "data": {"minLength": 1},
194                "valid": true
195            },
196            {
197                "description": "remote ref invalid",
198                "data": {"minLength": -1},
199                "valid": false
200            }
201        ]
202    },
203    {
204        "description": "property named $ref that is not a reference",
205        "schema": {
206            "$schema": "https://json-schema.org/draft/2020-12/schema",
207            "properties": {
208                "$ref": {"type": "string"}
209            }
210        },
211        "tests": [
212            {
213                "description": "property named $ref valid",
214                "data": {"$ref": "a"},
215                "valid": true
216            },
217            {
218                "description": "property named $ref invalid",
219                "data": {"$ref": 2},
220                "valid": false
221            }
222        ]
223    },
224    {
225        "description": "property named $ref, containing an actual $ref",
226        "schema": {
227            "$schema": "https://json-schema.org/draft/2020-12/schema",
228            "properties": {
229                "$ref": {"$ref": "#/$defs/is-string"}
230            },
231            "$defs": {
232                "is-string": {
233                    "type": "string"
234                }
235            }
236        },
237        "tests": [
238            {
239                "description": "property named $ref valid",
240                "data": {"$ref": "a"},
241                "valid": true
242            },
243            {
244                "description": "property named $ref invalid",
245                "data": {"$ref": 2},
246                "valid": false
247            }
248        ]
249    },
250    {
251        "description": "$ref to boolean schema true",
252        "schema": {
253            "$schema": "https://json-schema.org/draft/2020-12/schema",
254            "$ref": "#/$defs/bool",
255            "$defs": {
256                "bool": true
257            }
258        },
259        "tests": [
260            {
261                "description": "any value is valid",
262                "data": "foo",
263                "valid": true
264            }
265        ]
266    },
267    {
268        "description": "$ref to boolean schema false",
269        "schema": {
270            "$schema": "https://json-schema.org/draft/2020-12/schema",
271            "$ref": "#/$defs/bool",
272            "$defs": {
273                "bool": false
274            }
275        },
276        "tests": [
277            {
278                "description": "any value is invalid",
279                "data": "foo",
280                "valid": false
281            }
282        ]
283    },
284    {
285        "description": "Recursive references between schemas",
286        "schema": {
287            "$schema": "https://json-schema.org/draft/2020-12/schema",
288            "$id": "http://localhost:1234/draft2020-12/tree",
289            "description": "tree of nodes",
290            "type": "object",
291            "properties": {
292                "meta": {"type": "string"},
293                "nodes": {
294                    "type": "array",
295                    "items": {"$ref": "node"}
296                }
297            },
298            "required": ["meta", "nodes"],
299            "$defs": {
300                "node": {
301                    "$id": "http://localhost:1234/draft2020-12/node",
302                    "description": "node",
303                    "type": "object",
304                    "properties": {
305                        "value": {"type": "number"},
306                        "subtree": {"$ref": "tree"}
307                    },
308                    "required": ["value"]
309                }
310            }
311        },
312        "tests": [
313            {
314                "description": "valid tree",
315                "data": {
316                    "meta": "root",
317                    "nodes": [
318                        {
319                            "value": 1,
320                            "subtree": {
321                                "meta": "child",
322                                "nodes": [
323                                    {"value": 1.1},
324                                    {"value": 1.2}
325                                ]
326                            }
327                        },
328                        {
329                            "value": 2,
330                            "subtree": {
331                                "meta": "child",
332                                "nodes": [
333                                    {"value": 2.1},
334                                    {"value": 2.2}
335                                ]
336                            }
337                        }
338                    ]
339                },
340                "valid": true
341            },
342            {
343                "description": "invalid tree",
344                "data": {
345                    "meta": "root",
346                    "nodes": [
347                        {
348                            "value": 1,
349                            "subtree": {
350                                "meta": "child",
351                                "nodes": [
352                                    {"value": "string is invalid"},
353                                    {"value": 1.2}
354                                ]
355                            }
356                        },
357                        {
358                            "value": 2,
359                            "subtree": {
360                                "meta": "child",
361                                "nodes": [
362                                    {"value": 2.1},
363                                    {"value": 2.2}
364                                ]
365                            }
366                        }
367                    ]
368                },
369                "valid": false
370            }
371        ]
372    },
373    {
374        "description": "refs with quote",
375        "schema": {
376            "$schema": "https://json-schema.org/draft/2020-12/schema",
377            "properties": {
378                "foo\"bar": {"$ref": "#/$defs/foo%22bar"}
379            },
380            "$defs": {
381                "foo\"bar": {"type": "number"}
382            }
383        },
384        "tests": [
385            {
386                "description": "object with numbers is valid",
387                "data": {
388                    "foo\"bar": 1
389                },
390                "valid": true
391            },
392            {
393                "description": "object with strings is invalid",
394                "data": {
395                    "foo\"bar": "1"
396                },
397                "valid": false
398            }
399        ]
400    },
401    {
402        "description": "ref creates new scope when adjacent to keywords",
403        "schema": {
404            "$schema": "https://json-schema.org/draft/2020-12/schema",
405            "$defs": {
406                "A": {
407                    "unevaluatedProperties": false
408                }
409            },
410            "properties": {
411                "prop1": {
412                    "type": "string"
413                }
414            },
415            "$ref": "#/$defs/A"
416        },
417        "tests": [
418            {
419                "description": "referenced subschema doesn't see annotations from properties",
420                "data": {
421                    "prop1": "match"
422                },
423                "valid": false
424            }
425        ]
426    },
427    {
428        "description": "naive replacement of $ref with its destination is not correct",
429        "schema": {
430            "$schema": "https://json-schema.org/draft/2020-12/schema",
431            "$defs": {
432                "a_string": { "type": "string" }
433            },
434            "enum": [
435                { "$ref": "#/$defs/a_string" }
436            ]
437        },
438        "tests": [
439            {
440                "description": "do not evaluate the $ref inside the enum, matching any string",
441                "data": "this is a string",
442                "valid": false
443            },
444            {
445                "description": "do not evaluate the $ref inside the enum, definition exact match",
446                "data": { "type": "string" },
447                "valid": false
448            },
449            {
450                "description": "match the enum exactly",
451                "data": { "$ref": "#/$defs/a_string" },
452                "valid": true
453            }
454        ]
455    },
456    {
457        "description": "refs with relative uris and defs",
458        "schema": {
459            "$schema": "https://json-schema.org/draft/2020-12/schema",
460            "$id": "http://example.com/schema-relative-uri-defs1.json",
461            "properties": {
462                "foo": {
463                    "$id": "schema-relative-uri-defs2.json",
464                    "$defs": {
465                        "inner": {
466                            "properties": {
467                                "bar": { "type": "string" }
468                            }
469                        }
470                    },
471                    "$ref": "#/$defs/inner"
472                }
473            },
474            "$ref": "schema-relative-uri-defs2.json"
475        },
476        "tests": [
477            {
478                "description": "invalid on inner field",
479                "data": {
480                    "foo": {
481                        "bar": 1
482                    },
483                    "bar": "a"
484                },
485                "valid": false
486            },
487            {
488                "description": "invalid on outer field",
489                "data": {
490                    "foo": {
491                        "bar": "a"
492                    },
493                    "bar": 1
494                },
495                "valid": false
496            },
497            {
498                "description": "valid on both fields",
499                "data": {
500                    "foo": {
501                        "bar": "a"
502                    },
503                    "bar": "a"
504                },
505                "valid": true
506            }
507        ]
508    },
509    {
510        "description": "relative refs with absolute uris and defs",
511        "schema": {
512            "$schema": "https://json-schema.org/draft/2020-12/schema",
513            "$id": "http://example.com/schema-refs-absolute-uris-defs1.json",
514            "properties": {
515                "foo": {
516                    "$id": "http://example.com/schema-refs-absolute-uris-defs2.json",
517                    "$defs": {
518                        "inner": {
519                            "properties": {
520                                "bar": { "type": "string" }
521                            }
522                        }
523                    },
524                    "$ref": "#/$defs/inner"
525                }
526            },
527            "$ref": "schema-refs-absolute-uris-defs2.json"
528        },
529        "tests": [
530            {
531                "description": "invalid on inner field",
532                "data": {
533                    "foo": {
534                        "bar": 1
535                    },
536                    "bar": "a"
537                },
538                "valid": false
539            },
540            {
541                "description": "invalid on outer field",
542                "data": {
543                    "foo": {
544                        "bar": "a"
545                    },
546                    "bar": 1
547                },
548                "valid": false
549            },
550            {
551                "description": "valid on both fields",
552                "data": {
553                    "foo": {
554                        "bar": "a"
555                    },
556                    "bar": "a"
557                },
558                "valid": true
559            }
560        ]
561    },
562    {
563        "description": "$id must be resolved against nearest parent, not just immediate parent",
564        "schema": {
565            "$schema": "https://json-schema.org/draft/2020-12/schema",
566            "$id": "http://example.com/a.json",
567            "$defs": {
568                "x": {
569                    "$id": "http://example.com/b/c.json",
570                    "not": {
571                        "$defs": {
572                            "y": {
573                                "$id": "d.json",
574                                "type": "number"
575                            }
576                        }
577                    }
578                }
579            },
580            "allOf": [
581                {
582                    "$ref": "http://example.com/b/d.json"
583                }
584            ]
585        },
586        "tests": [
587            {
588                "description": "number is valid",
589                "data": 1,
590                "valid": true
591            },
592            {
593                "description": "non-number is invalid",
594                "data": "a",
595                "valid": false
596            }
597        ]
598    },
599    {
600        "description": "order of evaluation: $id and $ref",
601        "schema": {
602            "$comment": "$id must be evaluated before $ref to get the proper $ref destination",
603            "$schema": "https://json-schema.org/draft/2020-12/schema",
604            "$id": "https://example.com/draft2020-12/ref-and-id1/base.json",
605            "$ref": "int.json",
606            "$defs": {
607                "bigint": {
608                    "$comment": "canonical uri: https://example.com/ref-and-id1/int.json",
609                    "$id": "int.json",
610                    "maximum": 10
611                },
612                "smallint": {
613                    "$comment": "canonical uri: https://example.com/ref-and-id1-int.json",
614                    "$id": "/draft2020-12/ref-and-id1-int.json",
615                    "maximum": 2
616                }
617            }
618        },
619        "tests": [
620            {
621                "description": "data is valid against first definition",
622                "data": 5,
623                "valid": true
624            },
625            {
626                "description": "data is invalid against first definition",
627                "data": 50,
628                "valid": false
629            }
630        ]
631    },
632    {
633        "description": "order of evaluation: $id and $anchor and $ref",
634        "schema": {
635            "$comment": "$id must be evaluated before $ref to get the proper $ref destination",
636            "$schema": "https://json-schema.org/draft/2020-12/schema",
637            "$id": "https://example.com/draft2020-12/ref-and-id2/base.json",
638            "$ref": "#bigint",
639            "$defs": {
640                "bigint": {
641                    "$comment": "canonical uri: /ref-and-id2/base.json#/$defs/bigint; another valid uri for this location: /ref-and-id2/base.json#bigint",
642                    "$anchor": "bigint",
643                    "maximum": 10
644                },
645                "smallint": {
646                    "$comment": "canonical uri: https://example.com/ref-and-id2#/$defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint",
647                    "$id": "https://example.com/draft2020-12/ref-and-id2/",
648                    "$anchor": "bigint",
649                    "maximum": 2
650                }
651            }
652        },
653        "tests": [
654            {
655                "description": "data is valid against first definition",
656                "data": 5,
657                "valid": true
658            },
659            {
660                "description": "data is invalid against first definition",
661                "data": 50,
662                "valid": false
663            }
664        ]
665    },
666    {
667        "description": "simple URN base URI with $ref via the URN",
668        "schema": {
669            "$comment": "URIs do not have to have HTTP(s) schemes",
670            "$schema": "https://json-schema.org/draft/2020-12/schema",
671            "$id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed",
672            "minimum": 30,
673            "properties": {
674                "foo": {"$ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed"}
675            }
676        },
677        "tests": [
678            {
679                "description": "valid under the URN IDed schema",
680                "data": {"foo": 37},
681                "valid": true
682            },
683            {
684                "description": "invalid under the URN IDed schema",
685                "data": {"foo": 12},
686                "valid": false
687            }
688        ]
689    },
690    {
691        "description": "simple URN base URI with JSON pointer",
692        "schema": {
693            "$comment": "URIs do not have to have HTTP(s) schemes",
694            "$schema": "https://json-schema.org/draft/2020-12/schema",
695            "$id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed",
696            "properties": {
697                "foo": {"$ref": "#/$defs/bar"}
698            },
699            "$defs": {
700                "bar": {"type": "string"}
701            }
702        },
703        "tests": [
704            {
705                "description": "a string is valid",
706                "data": {"foo": "bar"},
707                "valid": true
708            },
709            {
710                "description": "a non-string is invalid",
711                "data": {"foo": 12},
712                "valid": false
713            }
714        ]
715    },
716    {
717        "description": "URN base URI with NSS",
718        "schema": {
719            "$comment": "RFC 8141 §2.2",
720            "$schema": "https://json-schema.org/draft/2020-12/schema",
721            "$id": "urn:example:1/406/47452/2",
722            "properties": {
723                "foo": {"$ref": "#/$defs/bar"}
724            },
725            "$defs": {
726                "bar": {"type": "string"}
727            }
728        },
729        "tests": [
730            {
731                "description": "a string is valid",
732                "data": {"foo": "bar"},
733                "valid": true
734            },
735            {
736                "description": "a non-string is invalid",
737                "data": {"foo": 12},
738                "valid": false
739            }
740        ]
741    },
742    {
743        "description": "URN base URI with r-component",
744        "schema": {
745            "$comment": "RFC 8141 §2.3.1",
746            "$schema": "https://json-schema.org/draft/2020-12/schema",
747            "$id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk",
748            "properties": {
749                "foo": {"$ref": "#/$defs/bar"}
750            },
751            "$defs": {
752                "bar": {"type": "string"}
753            }
754        },
755        "tests": [
756            {
757                "description": "a string is valid",
758                "data": {"foo": "bar"},
759                "valid": true
760            },
761            {
762                "description": "a non-string is invalid",
763                "data": {"foo": 12},
764                "valid": false
765            }
766        ]
767    },
768    {
769        "description": "URN base URI with q-component",
770        "schema": {
771            "$comment": "RFC 8141 §2.3.2",
772            "$schema": "https://json-schema.org/draft/2020-12/schema",
773            "$id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z",
774            "properties": {
775                "foo": {"$ref": "#/$defs/bar"}
776            },
777            "$defs": {
778                "bar": {"type": "string"}
779            }
780        },
781        "tests": [
782            {
783                "description": "a string is valid",
784                "data": {"foo": "bar"},
785                "valid": true
786            },
787            {
788                "description": "a non-string is invalid",
789                "data": {"foo": 12},
790                "valid": false
791            }
792        ]
793    },
794    {
795        "description": "URN base URI with f-component",
796        "schema": {
797            "$comment": "RFC 8141 §2.3.3, but we don't allow fragments",
798            "$schema": "https://json-schema.org/draft/2020-12/schema",
799            "$ref": "https://json-schema.org/draft/2020-12/schema"
800        },
801        "tests": [
802            {
803                "description": "is invalid",
804                "data": {"$id": "urn:example:foo-bar-baz-qux#somepart"},
805                "valid": false
806            }
807        ]
808    },
809    {
810        "description": "URN base URI with URN and JSON pointer ref",
811        "schema": {
812            "$schema": "https://json-schema.org/draft/2020-12/schema",
813            "$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
814            "properties": {
815                "foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"}
816            },
817            "$defs": {
818                "bar": {"type": "string"}
819            }
820        },
821        "tests": [
822            {
823                "description": "a string is valid",
824                "data": {"foo": "bar"},
825                "valid": true
826            },
827            {
828                "description": "a non-string is invalid",
829                "data": {"foo": 12},
830                "valid": false
831            }
832        ]
833    },
834    {
835        "description": "URN base URI with URN and anchor ref",
836        "schema": {
837            "$schema": "https://json-schema.org/draft/2020-12/schema",
838            "$id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed",
839            "properties": {
840                "foo": {"$ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something"}
841            },
842            "$defs": {
843                "bar": {
844                    "$anchor": "something",
845                    "type": "string"
846                }
847            }
848        },
849        "tests": [
850            {
851                "description": "a string is valid",
852                "data": {"foo": "bar"},
853                "valid": true
854            },
855            {
856                "description": "a non-string is invalid",
857                "data": {"foo": 12},
858                "valid": false
859            }
860        ]
861    },
862    {
863        "description": "URN ref with nested pointer ref",
864        "schema": {
865            "$schema": "https://json-schema.org/draft/2020-12/schema",
866            "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
867            "$defs": {
868                "foo": {
869                    "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
870                    "$defs": {"bar": {"type": "string"}},
871                    "$ref": "#/$defs/bar"
872                }
873            }
874        },
875        "tests": [
876            {
877                "description": "a string is valid",
878                "data": "bar",
879                "valid": true
880            },
881            {
882                "description": "a non-string is invalid",
883                "data": 12,
884                "valid": false
885            }
886        ]
887    },
888    {
889        "description": "ref to if",
890        "schema": {
891            "$schema": "https://json-schema.org/draft/2020-12/schema",
892            "$ref": "http://example.com/ref/if",
893            "if": {
894                "$id": "http://example.com/ref/if",
895                "type": "integer"
896            }
897        },
898        "tests": [
899            {
900                "description": "a non-integer is invalid due to the $ref",
901                "data": "foo",
902                "valid": false
903            },
904            {
905                "description": "an integer is valid",
906                "data": 12,
907                "valid": true
908            }
909        ]
910    },
911    {
912        "description": "ref to then",
913        "schema": {
914            "$schema": "https://json-schema.org/draft/2020-12/schema",
915            "$ref": "http://example.com/ref/then",
916            "then": {
917                "$id": "http://example.com/ref/then",
918                "type": "integer"
919            }
920        },
921        "tests": [
922            {
923                "description": "a non-integer is invalid due to the $ref",
924                "data": "foo",
925                "valid": false
926            },
927            {
928                "description": "an integer is valid",
929                "data": 12,
930                "valid": true
931            }
932        ]
933    },
934    {
935        "description": "ref to else",
936        "schema": {
937            "$schema": "https://json-schema.org/draft/2020-12/schema",
938            "$ref": "http://example.com/ref/else",
939            "else": {
940                "$id": "http://example.com/ref/else",
941                "type": "integer"
942            }
943        },
944        "tests": [
945            {
946                "description": "a non-integer is invalid due to the $ref",
947                "data": "foo",
948                "valid": false
949            },
950            {
951                "description": "an integer is valid",
952                "data": 12,
953                "valid": true
954            }
955        ]
956    },
957    {
958        "description": "ref with absolute-path-reference",
959        "schema": {
960            "$schema": "https://json-schema.org/draft/2020-12/schema",
961            "$id": "http://example.com/ref/absref.json",
962            "$defs": {
963                "a": {
964                    "$id": "http://example.com/ref/absref/foobar.json",
965                    "type": "number"
966                },
967                "b": {
968                    "$id": "http://example.com/absref/foobar.json",
969                    "type": "string"
970                }
971            },
972            "$ref": "/absref/foobar.json"
973        },
974        "tests": [
975            {
976                "description": "a string is valid",
977                "data": "foo",
978                "valid": true
979            },
980            {
981                "description": "an integer is invalid",
982                "data": 12,
983                "valid": false
984            }
985        ]
986    },
987    {
988        "description": "$id with file URI still resolves pointers - *nix",
989        "schema": {
990            "$schema": "https://json-schema.org/draft/2020-12/schema",
991            "$id": "file:///folder/file.json",
992            "$defs": {
993                "foo": {
994                    "type": "number"
995                }
996            },
997            "$ref": "#/$defs/foo"
998        },
999        "tests": [
1000            {
1001                "description": "number is valid",
1002                "data": 1,
1003                "valid": true
1004            },
1005            {
1006                "description": "non-number is invalid",
1007                "data": "a",
1008                "valid": false
1009            }
1010        ]
1011    },
1012    {
1013        "description": "$id with file URI still resolves pointers - windows",
1014        "schema": {
1015            "$schema": "https://json-schema.org/draft/2020-12/schema",
1016            "$id": "file:///c:/folder/file.json",
1017            "$defs": {
1018                "foo": {
1019                    "type": "number"
1020                }
1021            },
1022            "$ref": "#/$defs/foo"
1023        },
1024        "tests": [
1025            {
1026                "description": "number is valid",
1027                "data": 1,
1028                "valid": true
1029            },
1030            {
1031                "description": "non-number is invalid",
1032                "data": "a",
1033                "valid": false
1034            }
1035        ]
1036    },
1037    {
1038        "description": "empty tokens in $ref json-pointer",
1039        "schema": {
1040            "$schema": "https://json-schema.org/draft/2020-12/schema",
1041            "$defs": {
1042                "": {
1043                    "$defs": {
1044                        "": { "type": "number" }
1045                    }
1046                }
1047            },
1048            "allOf": [
1049                {
1050                    "$ref": "#/$defs//$defs/"
1051                }
1052            ]
1053        },
1054        "tests": [
1055            {
1056                "description": "number is valid",
1057                "data": 1,
1058                "valid": true
1059            },
1060            {
1061                "description": "non-number is invalid",
1062                "data": "a",
1063                "valid": false
1064            }
1065        ]
1066    }
1067]
1068