• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[
2    {
3        "description": "Location-independent identifier",
4        "schema": {
5            "$schema": "https://json-schema.org/draft/2019-09/schema",
6            "$ref": "#foo",
7            "$defs": {
8                "A": {
9                    "$anchor": "foo",
10                    "type": "integer"
11                }
12            }
13        },
14        "tests": [
15            {
16                "data": 1,
17                "description": "match",
18                "valid": true
19            },
20            {
21                "data": "a",
22                "description": "mismatch",
23                "valid": false
24            }
25        ]
26    },
27    {
28        "description": "Location-independent identifier with absolute URI",
29        "schema": {
30            "$schema": "https://json-schema.org/draft/2019-09/schema",
31            "$ref": "http://localhost:1234/draft2019-09/bar#foo",
32            "$defs": {
33                "A": {
34                    "$id": "http://localhost:1234/draft2019-09/bar",
35                    "$anchor": "foo",
36                    "type": "integer"
37                }
38            }
39        },
40        "tests": [
41            {
42                "data": 1,
43                "description": "match",
44                "valid": true
45            },
46            {
47                "data": "a",
48                "description": "mismatch",
49                "valid": false
50            }
51        ]
52    },
53    {
54        "description": "Location-independent identifier with base URI change in subschema",
55        "schema": {
56            "$schema": "https://json-schema.org/draft/2019-09/schema",
57            "$id": "http://localhost:1234/draft2019-09/root",
58            "$ref": "http://localhost:1234/draft2019-09/nested.json#foo",
59            "$defs": {
60                "A": {
61                    "$id": "nested.json",
62                    "$defs": {
63                        "B": {
64                            "$anchor": "foo",
65                            "type": "integer"
66                        }
67                    }
68                }
69            }
70        },
71        "tests": [
72            {
73                "data": 1,
74                "description": "match",
75                "valid": true
76            },
77            {
78                "data": "a",
79                "description": "mismatch",
80                "valid": false
81            }
82        ]
83    },
84    {
85        "description": "same $anchor with different base uri",
86        "schema": {
87            "$schema": "https://json-schema.org/draft/2019-09/schema",
88            "$id": "http://localhost:1234/draft2019-09/foobar",
89            "$defs": {
90                "A": {
91                    "$id": "child1",
92                    "allOf": [
93                        {
94                            "$id": "child2",
95                            "$anchor": "my_anchor",
96                            "type": "number"
97                        },
98                        {
99                            "$anchor": "my_anchor",
100                            "type": "string"
101                        }
102                    ]
103                }
104            },
105            "$ref": "child1#my_anchor"
106        },
107        "tests": [
108            {
109                "description": "$ref resolves to /$defs/A/allOf/1",
110                "data": "a",
111                "valid": true
112            },
113            {
114                "description": "$ref does not resolve to /$defs/A/allOf/0",
115                "data": 1,
116                "valid": false
117            }
118        ]
119    },
120    {
121        "description": "invalid anchors",
122        "comment": "Section 8.2.3",
123        "schema": {
124            "$schema": "https://json-schema.org/draft/2019-09/schema",
125            "$ref": "https://json-schema.org/draft/2019-09/schema"
126        },
127        "tests": [
128            {
129                "description": "MUST start with a letter (and not #)",
130                "data": { "$anchor" : "#foo" },
131                "valid": false
132            },
133            {
134                "description": "JSON pointers are not valid",
135                "data": { "$anchor" : "/a/b" },
136                "valid": false
137            },
138            {
139                "description": "invalid with valid beginning",
140                "data": { "$anchor" : "foo#something" },
141                "valid": false
142            }
143        ]
144    }
145]
146