|
393 | 393 | "$schema": "https://json-schema.org/draft/2020-12/schema",
|
394 | 394 | "$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main",
|
395 | 395 | "if": {
|
396 |
| - "propertyNames": { |
397 |
| - "pattern": "^[a-m]" |
398 |
| - } |
399 |
| - }, |
400 |
| - "then": { |
401 |
| - "$id": "numberValues", |
402 |
| - "$defs": { |
403 |
| - "foo": { |
404 |
| - "$dynamicAnchor": "foo", |
405 |
| - "type": "number" |
406 |
| - } |
407 |
| - }, |
408 |
| - "$ref": "inner" |
409 |
| - }, |
410 |
| - "else": { |
411 |
| - "$id": "stringValues", |
412 |
| - "$defs": { |
413 |
| - "foo": { |
414 |
| - "$dynamicAnchor": "foo", |
415 |
| - "type": "string" |
416 |
| - } |
| 396 | + "properties": { |
| 397 | + "kindOfList": { "const": "numbers" } |
417 | 398 | },
|
418 |
| - "$ref": "inner" |
| 399 | + "required": ["kindOfList"] |
419 | 400 | },
|
| 401 | + "then": { "$ref": "numberList" }, |
| 402 | + "else": { "$ref": "stringList" }, |
| 403 | + |
420 | 404 | "$defs": {
|
421 |
| - "inner": { |
422 |
| - "$id": "inner", |
423 |
| - "$dynamicAnchor": "foo", |
424 |
| - "additionalProperties": { |
425 |
| - "$dynamicRef": "#foo" |
| 405 | + "genericList": { |
| 406 | + "$id": "genericList", |
| 407 | + "properties": { |
| 408 | + "list": { |
| 409 | + "items": { "$dynamicRef": "#itemType" } |
| 410 | + } |
| 411 | + }, |
| 412 | + "$defs": { |
| 413 | + "defaultItemType": { |
| 414 | + "$comment": "Only needed to satisfy bookending requirement", |
| 415 | + "$dynamicAnchor": "itemType" |
| 416 | + } |
426 | 417 | }
|
| 418 | + }, |
| 419 | + "numberList": { |
| 420 | + "$id": "numberList", |
| 421 | + "$defs": { |
| 422 | + "itemType": { |
| 423 | + "$dynamicAnchor": "itemType", |
| 424 | + "type": "number" |
| 425 | + } |
| 426 | + }, |
| 427 | + "$ref": "genericList" |
| 428 | + }, |
| 429 | + "stringList": { |
| 430 | + "$id": "stringList", |
| 431 | + "$defs": { |
| 432 | + "itemType": { |
| 433 | + "$dynamicAnchor": "itemType", |
| 434 | + "type": "string" |
| 435 | + } |
| 436 | + }, |
| 437 | + "$ref": "genericList" |
427 | 438 | }
|
428 | 439 | }
|
429 | 440 | },
|
430 | 441 | "tests": [
|
431 | 442 | {
|
432 |
| - "description": "alpha with number values", |
433 |
| - "data": { "alpha": 1.1 }, |
| 443 | + "description": "number list with number values", |
| 444 | + "data": { |
| 445 | + "kindOfList": "numbers", |
| 446 | + "list": [1.1] |
| 447 | + }, |
434 | 448 | "valid": true
|
435 | 449 | },
|
436 | 450 | {
|
437 |
| - "description": "alpha with string values", |
438 |
| - "data": { "alpha": "foo" }, |
| 451 | + "description": "number list with string values", |
| 452 | + "data": { |
| 453 | + "kindOfList": "numbers", |
| 454 | + "list": ["foo"] |
| 455 | + }, |
439 | 456 | "valid": false
|
440 | 457 | },
|
441 | 458 | {
|
442 |
| - "description": "november with number values", |
443 |
| - "data": { "november": 1.1 }, |
| 459 | + "description": "string list with number values", |
| 460 | + "data": { |
| 461 | + "kindOfList": "strings", |
| 462 | + "list": [1.1] |
| 463 | + }, |
444 | 464 | "valid": false
|
445 | 465 | },
|
446 | 466 | {
|
447 |
| - "description": "november with string values", |
448 |
| - "data": { "november": "foo" }, |
| 467 | + "description": "string list with string values", |
| 468 | + "data": { |
| 469 | + "kindOfList": "strings", |
| 470 | + "list": ["foo"] |
| 471 | + }, |
449 | 472 | "valid": true
|
450 | 473 | }
|
451 | 474 | ]
|
|
0 commit comments