@@ -425,6 +425,66 @@ def test_multiple_nesting(self):
425
425
self .assertEqual (e5 .validator , "minItems" )
426
426
self .assertEqual (e6 .validator , "enum" )
427
427
428
+ def test_recursive (self ):
429
+ schema = {
430
+ "definitions" : {
431
+ "node" : {
432
+ "anyOf" : [{
433
+ "type" : "object" ,
434
+ "required" : ["name" , "children" ],
435
+ "properties" : {
436
+ "name" : {
437
+ "type" : "string" ,
438
+ },
439
+ "children" : {
440
+ "type" : "object" ,
441
+ "patternProperties" : {
442
+ "^.*$" : {
443
+ "$ref" : "#/definitions/node" ,
444
+ },
445
+ },
446
+ },
447
+ },
448
+ }],
449
+ },
450
+ },
451
+ "type" : "object" ,
452
+ "required" : ["root" ],
453
+ "properties" : {
454
+ "root" : {"$ref" : "#/definitions/node" },
455
+ }
456
+ }
457
+
458
+ instance = {
459
+ "root" : {
460
+ "name" : "root" ,
461
+ "children" : {
462
+ "a" : {
463
+ "name" : "a" ,
464
+ "children" : {
465
+ "ab" : {
466
+ "name" : "ab" ,
467
+ # missing "children"
468
+ }
469
+ }
470
+ },
471
+ },
472
+ },
473
+ }
474
+ validator = Draft4Validator (schema )
475
+
476
+ e , = validator .iter_errors (instance )
477
+ self .assertEqual (e .absolute_path , deque (["root" ]))
478
+ self .assertEqual (e .absolute_schema_path , deque (['properties' , 'root' , 'anyOf' ]))
479
+
480
+ e1 , = e .context
481
+ self .assertEqual (e1 .absolute_path , deque (['root' , 'children' , 'a' ]))
482
+ self .assertEqual (e .absolute_schema_path , deque (['properties' , 'root' , 'anyOf' ]))
483
+
484
+ e2 , = e1 .context
485
+ self .assertEqual (e2 .absolute_path , deque (['root' , 'children' , 'a' , 'children' , 'ab' ]))
486
+ self .assertEqual (e .absolute_schema_path , deque (['properties' , 'root' , 'anyOf' ]))
487
+
428
488
def test_additionalProperties (self ):
429
489
instance = {"bar" : "bar" , "foo" : 2 }
430
490
schema = {
0 commit comments