diff --git a/openapi_core/contrib/aiohttp/responses.py b/openapi_core/contrib/aiohttp/responses.py index 40771e2f..a7baf851 100644 --- a/openapi_core/contrib/aiohttp/responses.py +++ b/openapi_core/contrib/aiohttp/responses.py @@ -17,7 +17,10 @@ def data(self) -> str: if self.response.body is None: return "" if isinstance(self.response.body, bytes): - return self.response.body.decode("utf-8") + try: + return self.response.body.decode("utf-8") + except UnicodeDecodeError: + return self.response.body assert isinstance(self.response.body, str) return self.response.body