File tree 5 files changed +434
-2
lines changed
5 files changed +434
-2
lines changed Original file line number Diff line number Diff line change 78
78
]
79
79
},
80
80
{
81
- "description" : " A $dynamicRef should resolve to the first $dynamicAnchor that is encountered when the schema is evaluated" ,
81
+ "description" : " A $dynamicRef should resolve to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated" ,
82
82
"schema" : {
83
83
"$id" : " https://test.json-schema.org/typical-dynamic-resolution/root" ,
84
84
"$ref" : " list" ,
384
384
"valid" : false
385
385
}
386
386
]
387
+ },
388
+ {
389
+ "description" : " after leaving a dynamic scope, it should not be used by a $dynamicRef" ,
390
+ "schema" : {
391
+ "$id" : " https://test.json-schema.org/dynamic-ref-leaving-dynamic-scope/main" ,
392
+ "if" : {
393
+ "$id" : " first_scope" ,
394
+ "$defs" : {
395
+ "thingy" : {
396
+ "$comment" : " this is first_scope#thingy" ,
397
+ "$dynamicAnchor" : " thingy" ,
398
+ "type" : " number"
399
+ }
400
+ }
401
+ },
402
+ "then" : {
403
+ "$id" : " second_scope" ,
404
+ "$ref" : " start" ,
405
+ "$defs" : {
406
+ "thingy" : {
407
+ "$comment" : " this is second_scope#thingy, the final destination of the $dynamicRef" ,
408
+ "$dynamicAnchor" : " thingy" ,
409
+ "type" : " null"
410
+ }
411
+ }
412
+ },
413
+ "$defs" : {
414
+ "start" : {
415
+ "$comment" : " this is the landing spot from $ref" ,
416
+ "$id" : " start" ,
417
+ "$dynamicRef" : " inner_scope#thingy"
418
+ },
419
+ "thingy" : {
420
+ "$comment" : " this is the first stop for the $dynamicRef" ,
421
+ "$id" : " inner_scope" ,
422
+ "$dynamicAnchor" : " thingy" ,
423
+ "type" : " string"
424
+ }
425
+ }
426
+ },
427
+ "tests" : [
428
+ {
429
+ "description" : " string matches /$defs/thingy, but the $dynamicRef does not stop here" ,
430
+ "data" : " a string" ,
431
+ "valid" : false
432
+ },
433
+ {
434
+ "description" : " first_scope is not in dynamic scope for the $dynamicRef" ,
435
+ "data" : 42 ,
436
+ "valid" : false
437
+ },
438
+ {
439
+ "description" : " /then/$defs/thingy is the final stop for the $dynamicRef" ,
440
+ "data" : null ,
441
+ "valid" : true
442
+ }
443
+ ]
387
444
}
388
445
]
Original file line number Diff line number Diff line change 491
491
}
492
492
]
493
493
},
494
+ {
495
+ "description" : " unevaluatedProperties with if/then/else, then not defined" ,
496
+ "schema" : {
497
+ "type" : " object" ,
498
+ "if" : {
499
+ "properties" : {
500
+ "foo" : { "const" : " then" }
501
+ },
502
+ "required" : [" foo" ]
503
+ },
504
+ "else" : {
505
+ "properties" : {
506
+ "baz" : { "type" : " string" }
507
+ },
508
+ "required" : [" baz" ]
509
+ },
510
+ "unevaluatedProperties" : false
511
+ },
512
+ "tests" : [
513
+ {
514
+ "description" : " when if is true and has no unevaluated properties" ,
515
+ "data" : {
516
+ "foo" : " then" ,
517
+ "bar" : " bar"
518
+ },
519
+ "valid" : false
520
+ },
521
+ {
522
+ "description" : " when if is true and has unevaluated properties" ,
523
+ "data" : {
524
+ "foo" : " then" ,
525
+ "bar" : " bar" ,
526
+ "baz" : " baz"
527
+ },
528
+ "valid" : false
529
+ },
530
+ {
531
+ "description" : " when if is false and has no unevaluated properties" ,
532
+ "data" : {
533
+ "baz" : " baz"
534
+ },
535
+ "valid" : true
536
+ },
537
+ {
538
+ "description" : " when if is false and has unevaluated properties" ,
539
+ "data" : {
540
+ "foo" : " else" ,
541
+ "baz" : " baz"
542
+ },
543
+ "valid" : false
544
+ }
545
+ ]
546
+ },
547
+ {
548
+ "description" : " unevaluatedProperties with if/then/else, else not defined" ,
549
+ "schema" : {
550
+ "type" : " object" ,
551
+ "if" : {
552
+ "properties" : {
553
+ "foo" : { "const" : " then" }
554
+ },
555
+ "required" : [" foo" ]
556
+ },
557
+ "then" : {
558
+ "properties" : {
559
+ "bar" : { "type" : " string" }
560
+ },
561
+ "required" : [" bar" ]
562
+ },
563
+ "unevaluatedProperties" : false
564
+ },
565
+ "tests" : [
566
+ {
567
+ "description" : " when if is true and has no unevaluated properties" ,
568
+ "data" : {
569
+ "foo" : " then" ,
570
+ "bar" : " bar"
571
+ },
572
+ "valid" : true
573
+ },
574
+ {
575
+ "description" : " when if is true and has unevaluated properties" ,
576
+ "data" : {
577
+ "foo" : " then" ,
578
+ "bar" : " bar" ,
579
+ "baz" : " baz"
580
+ },
581
+ "valid" : false
582
+ },
583
+ {
584
+ "description" : " when if is false and has no unevaluated properties" ,
585
+ "data" : {
586
+ "baz" : " baz"
587
+ },
588
+ "valid" : false
589
+ },
590
+ {
591
+ "description" : " when if is false and has unevaluated properties" ,
592
+ "data" : {
593
+ "foo" : " else" ,
594
+ "baz" : " baz"
595
+ },
596
+ "valid" : false
597
+ }
598
+ ]
599
+ },
494
600
{
495
601
"description" : " unevaluatedProperties with dependentSchemas" ,
496
602
"schema" : {
Original file line number Diff line number Diff line change 491
491
}
492
492
]
493
493
},
494
+ {
495
+ "description" : " unevaluatedProperties with if/then/else, then not defined" ,
496
+ "schema" : {
497
+ "type" : " object" ,
498
+ "if" : {
499
+ "properties" : {
500
+ "foo" : { "const" : " then" }
501
+ },
502
+ "required" : [" foo" ]
503
+ },
504
+ "else" : {
505
+ "properties" : {
506
+ "baz" : { "type" : " string" }
507
+ },
508
+ "required" : [" baz" ]
509
+ },
510
+ "unevaluatedProperties" : false
511
+ },
512
+ "tests" : [
513
+ {
514
+ "description" : " when if is true and has no unevaluated properties" ,
515
+ "data" : {
516
+ "foo" : " then" ,
517
+ "bar" : " bar"
518
+ },
519
+ "valid" : false
520
+ },
521
+ {
522
+ "description" : " when if is true and has unevaluated properties" ,
523
+ "data" : {
524
+ "foo" : " then" ,
525
+ "bar" : " bar" ,
526
+ "baz" : " baz"
527
+ },
528
+ "valid" : false
529
+ },
530
+ {
531
+ "description" : " when if is false and has no unevaluated properties" ,
532
+ "data" : {
533
+ "baz" : " baz"
534
+ },
535
+ "valid" : true
536
+ },
537
+ {
538
+ "description" : " when if is false and has unevaluated properties" ,
539
+ "data" : {
540
+ "foo" : " else" ,
541
+ "baz" : " baz"
542
+ },
543
+ "valid" : false
544
+ }
545
+ ]
546
+ },
547
+ {
548
+ "description" : " unevaluatedProperties with if/then/else, else not defined" ,
549
+ "schema" : {
550
+ "type" : " object" ,
551
+ "if" : {
552
+ "properties" : {
553
+ "foo" : { "const" : " then" }
554
+ },
555
+ "required" : [" foo" ]
556
+ },
557
+ "then" : {
558
+ "properties" : {
559
+ "bar" : { "type" : " string" }
560
+ },
561
+ "required" : [" bar" ]
562
+ },
563
+ "unevaluatedProperties" : false
564
+ },
565
+ "tests" : [
566
+ {
567
+ "description" : " when if is true and has no unevaluated properties" ,
568
+ "data" : {
569
+ "foo" : " then" ,
570
+ "bar" : " bar"
571
+ },
572
+ "valid" : true
573
+ },
574
+ {
575
+ "description" : " when if is true and has unevaluated properties" ,
576
+ "data" : {
577
+ "foo" : " then" ,
578
+ "bar" : " bar" ,
579
+ "baz" : " baz"
580
+ },
581
+ "valid" : false
582
+ },
583
+ {
584
+ "description" : " when if is false and has no unevaluated properties" ,
585
+ "data" : {
586
+ "baz" : " baz"
587
+ },
588
+ "valid" : false
589
+ },
590
+ {
591
+ "description" : " when if is false and has unevaluated properties" ,
592
+ "data" : {
593
+ "foo" : " else" ,
594
+ "baz" : " baz"
595
+ },
596
+ "valid" : false
597
+ }
598
+ ]
599
+ },
494
600
{
495
601
"description" : " unevaluatedProperties with dependentSchemas" ,
496
602
"schema" : {
Original file line number Diff line number Diff line change 78
78
]
79
79
},
80
80
{
81
- "description" : " A $dynamicRef should resolve to the first $dynamicAnchor that is encountered when the schema is evaluated" ,
81
+ "description" : " A $dynamicRef should resolve to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated" ,
82
82
"schema" : {
83
83
"$id" : " https://test.json-schema.org/typical-dynamic-resolution/root" ,
84
84
"$ref" : " list" ,
384
384
"valid" : false
385
385
}
386
386
]
387
+ },
388
+ {
389
+ "description" : " after leaving a dynamic scope, it should not be used by a $dynamicRef" ,
390
+ "schema" : {
391
+ "$id" : " https://test.json-schema.org/dynamic-ref-leaving-dynamic-scope/main" ,
392
+ "if" : {
393
+ "$id" : " first_scope" ,
394
+ "$defs" : {
395
+ "thingy" : {
396
+ "$comment" : " this is first_scope#thingy" ,
397
+ "$dynamicAnchor" : " thingy" ,
398
+ "type" : " number"
399
+ }
400
+ }
401
+ },
402
+ "then" : {
403
+ "$id" : " second_scope" ,
404
+ "$ref" : " start" ,
405
+ "$defs" : {
406
+ "thingy" : {
407
+ "$comment" : " this is second_scope#thingy, the final destination of the $dynamicRef" ,
408
+ "$dynamicAnchor" : " thingy" ,
409
+ "type" : " null"
410
+ }
411
+ }
412
+ },
413
+ "$defs" : {
414
+ "start" : {
415
+ "$comment" : " this is the landing spot from $ref" ,
416
+ "$id" : " start" ,
417
+ "$dynamicRef" : " inner_scope#thingy"
418
+ },
419
+ "thingy" : {
420
+ "$comment" : " this is the first stop for the $dynamicRef" ,
421
+ "$id" : " inner_scope" ,
422
+ "$dynamicAnchor" : " thingy" ,
423
+ "type" : " string"
424
+ }
425
+ }
426
+ },
427
+ "tests" : [
428
+ {
429
+ "description" : " string matches /$defs/thingy, but the $dynamicRef does not stop here" ,
430
+ "data" : " a string" ,
431
+ "valid" : false
432
+ },
433
+ {
434
+ "description" : " first_scope is not in dynamic scope for the $dynamicRef" ,
435
+ "data" : 42 ,
436
+ "valid" : false
437
+ },
438
+ {
439
+ "description" : " /then/$defs/thingy is the final stop for the $dynamicRef" ,
440
+ "data" : null ,
441
+ "valid" : true
442
+ }
443
+ ]
387
444
}
388
445
]
You can’t perform that action at this time.
0 commit comments