| 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": "order of evaluation: $id and $ref on nested schema", |
| 668 |
"schema": { |
| 669 |
"$comment": "$id must be evaluated before $ref to get the proper $ref destination", |
| 670 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 671 |
"$id": "https://example.com/draft2020-12/ref-and-id3/base.json", |
| 672 |
"$ref": "nested/foo.json", |
| 673 |
"$defs": { |
| 674 |
"foo": { |
| 675 |
"$comment": "canonical uri: https://example.com/draft2020-12/ref-and-id3/nested/foo.json", |
| 676 |
"$id": "nested/foo.json", |
| 677 |
"$ref": "./bar.json" |
| 678 |
}, |
| 679 |
"bar": { |
| 680 |
"$comment": "canonical uri: https://example.com/draft2020-12/ref-and-id3/nested/bar.json", |
| 681 |
"$id": "nested/bar.json", |
| 682 |
"type": "number" |
| 683 |
} |
| 684 |
} |
| 685 |
}, |
| 686 |
"tests": [ |
| 687 |
{ |
| 688 |
"description": "data is valid against nested sibling", |
| 689 |
"data": 5, |
| 690 |
"valid": true |
| 691 |
}, |
| 692 |
{ |
| 693 |
"description": "data is invalid against nested sibling", |
| 694 |
"data": "a", |
| 695 |
"valid": false |
| 696 |
} |
| 697 |
] |
| 698 |
}, |
| 699 |
{ |
| 700 |
"description": "simple URN base URI with $ref via the URN", |
| 701 |
"schema": { |
| 702 |
"$comment": "URIs do not have to have HTTP(s) schemes", |
| 703 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 704 |
"$id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", |
| 705 |
"minimum": 30, |
| 706 |
"properties": { |
| 707 |
"foo": {"$ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed"} |
| 708 |
} |
| 709 |
}, |
| 710 |
"tests": [ |
| 711 |
{ |
| 712 |
"description": "valid under the URN IDed schema", |
| 713 |
"data": {"foo": 37}, |
| 714 |
"valid": true |
| 715 |
}, |
| 716 |
{ |
| 717 |
"description": "invalid under the URN IDed schema", |
| 718 |
"data": {"foo": 12}, |
| 719 |
"valid": false |
| 720 |
} |
| 721 |
] |
| 722 |
}, |
| 723 |
{ |
| 724 |
"description": "simple URN base URI with JSON pointer", |
| 725 |
"schema": { |
| 726 |
"$comment": "URIs do not have to have HTTP(s) schemes", |
| 727 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 728 |
"$id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", |
| 729 |
"properties": { |
| 730 |
"foo": {"$ref": "#/$defs/bar"} |
| 731 |
}, |
| 732 |
"$defs": { |
| 733 |
"bar": {"type": "string"} |
| 734 |
} |
| 735 |
}, |
| 736 |
"tests": [ |
| 737 |
{ |
| 738 |
"description": "a string is valid", |
| 739 |
"data": {"foo": "bar"}, |
| 740 |
"valid": true |
| 741 |
}, |
| 742 |
{ |
| 743 |
"description": "a non-string is invalid", |
| 744 |
"data": {"foo": 12}, |
| 745 |
"valid": false |
| 746 |
} |
| 747 |
] |
| 748 |
}, |
| 749 |
{ |
| 750 |
"description": "URN base URI with NSS", |
| 751 |
"schema": { |
| 752 |
"$comment": "RFC 8141 §2.2", |
| 753 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 754 |
"$id": "urn:example:1/406/47452/2", |
| 755 |
"properties": { |
| 756 |
"foo": {"$ref": "#/$defs/bar"} |
| 757 |
}, |
| 758 |
"$defs": { |
| 759 |
"bar": {"type": "string"} |
| 760 |
} |
| 761 |
}, |
| 762 |
"tests": [ |
| 763 |
{ |
| 764 |
"description": "a string is valid", |
| 765 |
"data": {"foo": "bar"}, |
| 766 |
"valid": true |
| 767 |
}, |
| 768 |
{ |
| 769 |
"description": "a non-string is invalid", |
| 770 |
"data": {"foo": 12}, |
| 771 |
"valid": false |
| 772 |
} |
| 773 |
] |
| 774 |
}, |
| 775 |
{ |
| 776 |
"description": "URN base URI with r-component", |
| 777 |
"schema": { |
| 778 |
"$comment": "RFC 8141 §2.3.1", |
| 779 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 780 |
"$id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", |
| 781 |
"properties": { |
| 782 |
"foo": {"$ref": "#/$defs/bar"} |
| 783 |
}, |
| 784 |
"$defs": { |
| 785 |
"bar": {"type": "string"} |
| 786 |
} |
| 787 |
}, |
| 788 |
"tests": [ |
| 789 |
{ |
| 790 |
"description": "a string is valid", |
| 791 |
"data": {"foo": "bar"}, |
| 792 |
"valid": true |
| 793 |
}, |
| 794 |
{ |
| 795 |
"description": "a non-string is invalid", |
| 796 |
"data": {"foo": 12}, |
| 797 |
"valid": false |
| 798 |
} |
| 799 |
] |
| 800 |
}, |
| 801 |
{ |
| 802 |
"description": "URN base URI with q-component", |
| 803 |
"schema": { |
| 804 |
"$comment": "RFC 8141 §2.3.2", |
| 805 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 806 |
"$id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z", |
| 807 |
"properties": { |
| 808 |
"foo": {"$ref": "#/$defs/bar"} |
| 809 |
}, |
| 810 |
"$defs": { |
| 811 |
"bar": {"type": "string"} |
| 812 |
} |
| 813 |
}, |
| 814 |
"tests": [ |
| 815 |
{ |
| 816 |
"description": "a string is valid", |
| 817 |
"data": {"foo": "bar"}, |
| 818 |
"valid": true |
| 819 |
}, |
| 820 |
{ |
| 821 |
"description": "a non-string is invalid", |
| 822 |
"data": {"foo": 12}, |
| 823 |
"valid": false |
| 824 |
} |
| 825 |
] |
| 826 |
}, |
| 827 |
{ |
| 828 |
"description": "URN base URI with URN and JSON pointer ref", |
| 829 |
"schema": { |
| 830 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 831 |
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", |
| 832 |
"properties": { |
| 833 |
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"} |
| 834 |
}, |
| 835 |
"$defs": { |
| 836 |
"bar": {"type": "string"} |
| 837 |
} |
| 838 |
}, |
| 839 |
"tests": [ |
| 840 |
{ |
| 841 |
"description": "a string is valid", |
| 842 |
"data": {"foo": "bar"}, |
| 843 |
"valid": true |
| 844 |
}, |
| 845 |
{ |
| 846 |
"description": "a non-string is invalid", |
| 847 |
"data": {"foo": 12}, |
| 848 |
"valid": false |
| 849 |
} |
| 850 |
] |
| 851 |
}, |
| 852 |
{ |
| 853 |
"description": "URN base URI with URN and anchor ref", |
| 854 |
"schema": { |
| 855 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 856 |
"$id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", |
| 857 |
"properties": { |
| 858 |
"foo": {"$ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something"} |
| 859 |
}, |
| 860 |
"$defs": { |
| 861 |
"bar": { |
| 862 |
"$anchor": "something", |
| 863 |
"type": "string" |
| 864 |
} |
| 865 |
} |
| 866 |
}, |
| 867 |
"tests": [ |
| 868 |
{ |
| 869 |
"description": "a string is valid", |
| 870 |
"data": {"foo": "bar"}, |
| 871 |
"valid": true |
| 872 |
}, |
| 873 |
{ |
| 874 |
"description": "a non-string is invalid", |
| 875 |
"data": {"foo": 12}, |
| 876 |
"valid": false |
| 877 |
} |
| 878 |
] |
| 879 |
}, |
| 880 |
{ |
| 881 |
"description": "URN ref with nested pointer ref", |
| 882 |
"schema": { |
| 883 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 884 |
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", |
| 885 |
"$defs": { |
| 886 |
"foo": { |
| 887 |
"$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", |
| 888 |
"$defs": {"bar": {"type": "string"}}, |
| 889 |
"$ref": "#/$defs/bar" |
| 890 |
} |
| 891 |
} |
| 892 |
}, |
| 893 |
"tests": [ |
| 894 |
{ |
| 895 |
"description": "a string is valid", |
| 896 |
"data": "bar", |
| 897 |
"valid": true |
| 898 |
}, |
| 899 |
{ |
| 900 |
"description": "a non-string is invalid", |
| 901 |
"data": 12, |
| 902 |
"valid": false |
| 903 |
} |
| 904 |
] |
| 905 |
}, |
| 906 |
{ |
| 907 |
"description": "ref to if", |
| 908 |
"schema": { |
| 909 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 910 |
"$ref": "http://example.com/ref/if", |
| 911 |
"if": { |
| 912 |
"$id": "http://example.com/ref/if", |
| 913 |
"type": "integer" |
| 914 |
} |
| 915 |
}, |
| 916 |
"tests": [ |
| 917 |
{ |
| 918 |
"description": "a non-integer is invalid due to the $ref", |
| 919 |
"data": "foo", |
| 920 |
"valid": false |
| 921 |
}, |
| 922 |
{ |
| 923 |
"description": "an integer is valid", |
| 924 |
"data": 12, |
| 925 |
"valid": true |
| 926 |
} |
| 927 |
] |
| 928 |
}, |
| 929 |
{ |
| 930 |
"description": "ref to then", |
| 931 |
"schema": { |
| 932 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 933 |
"$ref": "http://example.com/ref/then", |
| 934 |
"then": { |
| 935 |
"$id": "http://example.com/ref/then", |
| 936 |
"type": "integer" |
| 937 |
} |
| 938 |
}, |
| 939 |
"tests": [ |
| 940 |
{ |
| 941 |
"description": "a non-integer is invalid due to the $ref", |
| 942 |
"data": "foo", |
| 943 |
"valid": false |
| 944 |
}, |
| 945 |
{ |
| 946 |
"description": "an integer is valid", |
| 947 |
"data": 12, |
| 948 |
"valid": true |
| 949 |
} |
| 950 |
] |
| 951 |
}, |
| 952 |
{ |
| 953 |
"description": "ref to else", |
| 954 |
"schema": { |
| 955 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 956 |
"$ref": "http://example.com/ref/else", |
| 957 |
"else": { |
| 958 |
"$id": "http://example.com/ref/else", |
| 959 |
"type": "integer" |
| 960 |
} |
| 961 |
}, |
| 962 |
"tests": [ |
| 963 |
{ |
| 964 |
"description": "a non-integer is invalid due to the $ref", |
| 965 |
"data": "foo", |
| 966 |
"valid": false |
| 967 |
}, |
| 968 |
{ |
| 969 |
"description": "an integer is valid", |
| 970 |
"data": 12, |
| 971 |
"valid": true |
| 972 |
} |
| 973 |
] |
| 974 |
}, |
| 975 |
{ |
| 976 |
"description": "ref with absolute-path-reference", |
| 977 |
"schema": { |
| 978 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 979 |
"$id": "http://example.com/ref/absref.json", |
| 980 |
"$defs": { |
| 981 |
"a": { |
| 982 |
"$id": "http://example.com/ref/absref/foobar.json", |
| 983 |
"type": "number" |
| 984 |
}, |
| 985 |
"b": { |
| 986 |
"$id": "http://example.com/absref/foobar.json", |
| 987 |
"type": "string" |
| 988 |
} |
| 989 |
}, |
| 990 |
"$ref": "/absref/foobar.json" |
| 991 |
}, |
| 992 |
"tests": [ |
| 993 |
{ |
| 994 |
"description": "a string is valid", |
| 995 |
"data": "foo", |
| 996 |
"valid": true |
| 997 |
}, |
| 998 |
{ |
| 999 |
"description": "an integer is invalid", |
| 1000 |
"data": 12, |
| 1001 |
"valid": false |
| 1002 |
} |
| 1003 |
] |
| 1004 |
}, |
| 1005 |
{ |
| 1006 |
"description": "$id with file URI still resolves pointers - *nix", |
| 1007 |
"schema": { |
| 1008 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 1009 |
"$id": "file:///folder/file.json", |
| 1010 |
"$defs": { |
| 1011 |
"foo": { |
| 1012 |
"type": "number" |
| 1013 |
} |
| 1014 |
}, |
| 1015 |
"$ref": "#/$defs/foo" |
| 1016 |
}, |
| 1017 |
"tests": [ |
| 1018 |
{ |
| 1019 |
"description": "number is valid", |
| 1020 |
"data": 1, |
| 1021 |
"valid": true |
| 1022 |
}, |
| 1023 |
{ |
| 1024 |
"description": "non-number is invalid", |
| 1025 |
"data": "a", |
| 1026 |
"valid": false |
| 1027 |
} |
| 1028 |
] |
| 1029 |
}, |
| 1030 |
{ |
| 1031 |
"description": "$id with file URI still resolves pointers - windows", |
| 1032 |
"schema": { |
| 1033 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 1034 |
"$id": "file:///c:/folder/file.json", |
| 1035 |
"$defs": { |
| 1036 |
"foo": { |
| 1037 |
"type": "number" |
| 1038 |
} |
| 1039 |
}, |
| 1040 |
"$ref": "#/$defs/foo" |
| 1041 |
}, |
| 1042 |
"tests": [ |
| 1043 |
{ |
| 1044 |
"description": "number is valid", |
| 1045 |
"data": 1, |
| 1046 |
"valid": true |
| 1047 |
}, |
| 1048 |
{ |
| 1049 |
"description": "non-number is invalid", |
| 1050 |
"data": "a", |
| 1051 |
"valid": false |
| 1052 |
} |
| 1053 |
] |
| 1054 |
}, |
| 1055 |
{ |
| 1056 |
"description": "empty tokens in $ref json-pointer", |
| 1057 |
"schema": { |
| 1058 |
"$schema": "https://json-schema.org/draft/2020-12/schema", |
| 1059 |
"$defs": { |
| 1060 |
"": { |
| 1061 |
"$defs": { |
| 1062 |
"": { "type": "number" } |
| 1063 |
} |
| 1064 |
} |
| 1065 |
}, |
| 1066 |
"allOf": [ |
| 1067 |
{ |
| 1068 |
"$ref": "#/$defs//$defs/" |
| 1069 |
} |
| 1070 |
] |
| 1071 |
}, |
| 1072 |
"tests": [ |
| 1073 |
{ |
| 1074 |
"description": "number is valid", |
| 1075 |
"data": 1, |
| 1076 |
"valid": true |
| 1077 |
}, |
| 1078 |
{ |
| 1079 |
"description": "non-number is invalid", |
| 1080 |
"data": "a", |
| 1081 |
"valid": false |
| 1082 |
} |
| 1083 |
] |
| 1084 |
} |
| 1085 |
] |