1[ 2 { 3 "description": "Invalid use of fragments in location-independent $id", 4 "schema": { 5 "$schema": "https://json-schema.org/draft/2020-12/schema", 6 "$ref": "https://json-schema.org/draft/2020-12/schema" 7 }, 8 "tests": [ 9 { 10 "description": "Identifier name", 11 "data": { 12 "$ref": "#foo", 13 "$defs": { 14 "A": { 15 "$id": "#foo", 16 "type": "integer" 17 } 18 } 19 }, 20 "valid": false 21 }, 22 { 23 "description": "Identifier name and no ref", 24 "data": { 25 "$defs": { 26 "A": { "$id": "#foo" } 27 } 28 }, 29 "valid": false 30 }, 31 { 32 "description": "Identifier path", 33 "data": { 34 "$ref": "#/a/b", 35 "$defs": { 36 "A": { 37 "$id": "#/a/b", 38 "type": "integer" 39 } 40 } 41 }, 42 "valid": false 43 }, 44 { 45 "description": "Identifier name with absolute URI", 46 "data": { 47 "$ref": "http://localhost:1234/draft2020-12/bar#foo", 48 "$defs": { 49 "A": { 50 "$id": "http://localhost:1234/draft2020-12/bar#foo", 51 "type": "integer" 52 } 53 } 54 }, 55 "valid": false 56 }, 57 { 58 "description": "Identifier path with absolute URI", 59 "data": { 60 "$ref": "http://localhost:1234/draft2020-12/bar#/a/b", 61 "$defs": { 62 "A": { 63 "$id": "http://localhost:1234/draft2020-12/bar#/a/b", 64 "type": "integer" 65 } 66 } 67 }, 68 "valid": false 69 }, 70 { 71 "description": "Identifier name with base URI change in subschema", 72 "data": { 73 "$id": "http://localhost:1234/draft2020-12/root", 74 "$ref": "http://localhost:1234/draft2020-12/nested.json#foo", 75 "$defs": { 76 "A": { 77 "$id": "nested.json", 78 "$defs": { 79 "B": { 80 "$id": "#foo", 81 "type": "integer" 82 } 83 } 84 } 85 } 86 }, 87 "valid": false 88 }, 89 { 90 "description": "Identifier path with base URI change in subschema", 91 "data": { 92 "$id": "http://localhost:1234/draft2020-12/root", 93 "$ref": "http://localhost:1234/draft2020-12/nested.json#/a/b", 94 "$defs": { 95 "A": { 96 "$id": "nested.json", 97 "$defs": { 98 "B": { 99 "$id": "#/a/b", 100 "type": "integer" 101 } 102 } 103 } 104 } 105 }, 106 "valid": false 107 } 108 ] 109 }, 110 { 111 "description": "Valid use of empty fragments in location-independent $id", 112 "comment": "These are allowed but discouraged", 113 "schema": { 114 "$schema": "https://json-schema.org/draft/2020-12/schema", 115 "$ref": "https://json-schema.org/draft/2020-12/schema" 116 }, 117 "tests": [ 118 { 119 "description": "Identifier name with absolute URI", 120 "data": { 121 "$ref": "http://localhost:1234/draft2020-12/bar", 122 "$defs": { 123 "A": { 124 "$id": "http://localhost:1234/draft2020-12/bar#", 125 "type": "integer" 126 } 127 } 128 }, 129 "valid": true 130 }, 131 { 132 "description": "Identifier name with base URI change in subschema", 133 "data": { 134 "$id": "http://localhost:1234/draft2020-12/root", 135 "$ref": "http://localhost:1234/draft2020-12/nested.json#/$defs/B", 136 "$defs": { 137 "A": { 138 "$id": "nested.json", 139 "$defs": { 140 "B": { 141 "$id": "#", 142 "type": "integer" 143 } 144 } 145 } 146 } 147 }, 148 "valid": true 149 } 150 ] 151 }, 152 { 153 "description": "Unnormalized $ids are allowed but discouraged", 154 "schema": { 155 "$schema": "https://json-schema.org/draft/2020-12/schema", 156 "$ref": "https://json-schema.org/draft/2020-12/schema" 157 }, 158 "tests": [ 159 { 160 "description": "Unnormalized identifier", 161 "data": { 162 "$ref": "http://localhost:1234/draft2020-12/foo/baz", 163 "$defs": { 164 "A": { 165 "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz", 166 "type": "integer" 167 } 168 } 169 }, 170 "valid": true 171 }, 172 { 173 "description": "Unnormalized identifier and no ref", 174 "data": { 175 "$defs": { 176 "A": { 177 "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz", 178 "type": "integer" 179 } 180 } 181 }, 182 "valid": true 183 }, 184 { 185 "description": "Unnormalized identifier with empty fragment", 186 "data": { 187 "$ref": "http://localhost:1234/draft2020-12/foo/baz", 188 "$defs": { 189 "A": { 190 "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz#", 191 "type": "integer" 192 } 193 } 194 }, 195 "valid": true 196 }, 197 { 198 "description": "Unnormalized identifier with empty fragment and no ref", 199 "data": { 200 "$defs": { 201 "A": { 202 "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz#", 203 "type": "integer" 204 } 205 } 206 }, 207 "valid": true 208 } 209 ] 210 } 211] 212