@@ -582,3 +582,52 @@ def test_schema_ref(self):
582582
583583 error = "'id' is a required property"
584584 assert error in str (excinfo .value )
585+
586+ @pytest .mark .parametrize ('value' , [
587+ [1600 , "Pennsylvania" , "Avenue" , "NW" ],
588+ [1600 , "Pennsylvania" , "Avenue" ],
589+ ])
590+ def test_array_prefixitems (self , value ):
591+ schema = {
592+ "type" : 'array' ,
593+ "prefixItems" : [
594+ { "type" : "number" },
595+ { "type" : "string" },
596+ { "enum" : ["Street" , "Avenue" , "Boulevard" ] },
597+ { "enum" : ["NW" , "NE" , "SW" , "SE" ] }
598+ ],
599+ "items" : False ,
600+ }
601+ validator = OAS31Validator (
602+ schema ,
603+ format_checker = oas31_format_checker ,
604+ )
605+
606+ result = validator .validate (value )
607+
608+ assert result is None
609+
610+ @pytest .mark .parametrize ('value' , [
611+ [1600 , "Pennsylvania" , "Avenue" , "NW" , "Washington" ],
612+ ])
613+ def test_array_prefixitems_invalid (self , value ):
614+ schema = {
615+ "type" : 'array' ,
616+ "prefixItems" : [
617+ { "type" : "number" },
618+ { "type" : "string" },
619+ { "enum" : ["Street" , "Avenue" , "Boulevard" ] },
620+ { "enum" : ["NW" , "NE" , "SW" , "SE" ] }
621+ ],
622+ "items" : False ,
623+ }
624+ validator = OAS31Validator (
625+ schema ,
626+ format_checker = oas31_format_checker ,
627+ )
628+
629+ with pytest .raises (ValidationError ) as excinfo :
630+ validator .validate (value )
631+
632+ error = "Expected at most 4 items, but found 5"
633+ assert error in str (excinfo .value )
0 commit comments