55from typing import Iterator
66from typing import List
77from typing import Mapping
8+ from typing import Optional
89
910from jsonschema_path import SchemaPath
1011from openapi_spec_validator import OpenAPIV30SpecValidator
@@ -41,7 +42,7 @@ class BaseResponseValidator(BaseValidator):
4142 def _iter_errors (
4243 self ,
4344 status_code : int ,
44- data : str ,
45+ data : Optional [ bytes ] ,
4546 headers : Mapping [str , Any ],
4647 mimetype : str ,
4748 operation : SchemaPath ,
@@ -66,7 +67,11 @@ def _iter_errors(
6667 yield from exc .context
6768
6869 def _iter_data_errors (
69- self , status_code : int , data : str , mimetype : str , operation : SchemaPath
70+ self ,
71+ status_code : int ,
72+ data : Optional [bytes ],
73+ mimetype : str ,
74+ operation : SchemaPath ,
7075 ) -> Iterator [Exception ]:
7176 try :
7277 operation_response = self ._find_operation_response (
@@ -114,7 +119,10 @@ def _find_operation_response(
114119
115120 @ValidationErrorWrapper (DataValidationError , InvalidData )
116121 def _get_data (
117- self , data : str , mimetype : str , operation_response : SchemaPath
122+ self ,
123+ data : Optional [bytes ],
124+ mimetype : str ,
125+ operation_response : SchemaPath ,
118126 ) -> Any :
119127 if "content" not in operation_response :
120128 return None
@@ -125,7 +133,7 @@ def _get_data(
125133 value , _ = self ._get_content_and_schema (raw_data , content , mimetype )
126134 return value
127135
128- def _get_data_value (self , data : str ) -> Any :
136+ def _get_data_value (self , data : Optional [ bytes ] ) -> bytes :
129137 if not data :
130138 raise MissingData
131139
0 commit comments