33from typing import Hashable
44from typing import Iterator
55from typing import Mapping
6+ from typing import Optional
67from typing import Tuple
78
89from openapi_spec_validator .validation .exceptions import OpenAPIValidationError
@@ -21,10 +22,15 @@ def detect(self, instance: Mapping[Hashable, Any]) -> SpecValidator:
2122 raise ValidatorDetectError ("Spec schema version not detected" )
2223
2324 def validate (
24- self , instance : Mapping [Hashable , Any ], spec_url : str = ""
25+ self ,
26+ instance : Mapping [Hashable , Any ],
27+ base_uri : str = "" ,
28+ spec_url : Optional [str ] = None ,
2529 ) -> None :
2630 validator = self .detect (instance )
27- for err in validator .iter_errors (instance , spec_url = spec_url ):
31+ for err in validator .iter_errors (
32+ instance , base_uri = base_uri , spec_url = spec_url
33+ ):
2834 raise err
2935
3036 def is_valid (self , instance : Mapping [Hashable , Any ]) -> bool :
@@ -33,7 +39,12 @@ def is_valid(self, instance: Mapping[Hashable, Any]) -> bool:
3339 return error is None
3440
3541 def iter_errors (
36- self , instance : Mapping [Hashable , Any ], spec_url : str = ""
42+ self ,
43+ instance : Mapping [Hashable , Any ],
44+ base_uri : str = "" ,
45+ spec_url : Optional [str ] = None ,
3746 ) -> Iterator [OpenAPIValidationError ]:
3847 validator = self .detect (instance )
39- yield from validator .iter_errors (instance , spec_url = spec_url )
48+ yield from validator .iter_errors (
49+ instance , base_uri = base_uri , spec_url = spec_url
50+ )
0 commit comments