File tree 1 file changed +55
-0
lines changed
1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -559,6 +559,61 @@ def test_schema_any_any_of(self, unmarshaller_factory):
559
559
schema = SpecPath .from_spec (spec )
560
560
assert unmarshaller_factory (schema )(['hello' ]) == ['hello' ]
561
561
562
+ def test_schema_object_any_of (self , unmarshaller_factory ):
563
+ spec = {
564
+ 'type' : 'object' ,
565
+ 'anyOf' : [
566
+ {
567
+ 'type' : 'object' ,
568
+ 'required' : ['someint' ],
569
+ 'properties' : {
570
+ 'someint' : {
571
+ 'type' : 'integer'
572
+ }
573
+ }
574
+ },
575
+ {
576
+ 'type' : 'object' ,
577
+ 'required' : ['somestr' ],
578
+ 'properties' : {
579
+ 'somestr' : {
580
+ 'type' : 'string'
581
+ }
582
+ }
583
+ }
584
+ ],
585
+ }
586
+ schema = SpecPath .from_spec (spec )
587
+ assert unmarshaller_factory (schema )({'someint' : 1 }) == {'someint' : 1 }
588
+
589
+ def test_schema_object_any_of_invalid (self , unmarshaller_factory ):
590
+ spec = {
591
+ 'type' : 'object' ,
592
+ 'anyOf' : [
593
+ {
594
+ 'type' : 'object' ,
595
+ 'required' : ['someint' ],
596
+ 'properties' : {
597
+ 'someint' : {
598
+ 'type' : 'integer'
599
+ }
600
+ }
601
+ },
602
+ {
603
+ 'type' : 'object' ,
604
+ 'required' : ['somestr' ],
605
+ 'properties' : {
606
+ 'somestr' : {
607
+ 'type' : 'string'
608
+ }
609
+ }
610
+ }
611
+ ],
612
+ }
613
+ schema = SpecPath .from_spec (spec )
614
+ with pytest .raises (UnmarshalError ):
615
+ unmarshaller_factory (schema )({'someint' : '1' })
616
+
562
617
def test_schema_any_all_of (self , unmarshaller_factory ):
563
618
spec = {
564
619
'allOf' : [
You can’t perform that action at this time.
0 commit comments