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 diff --git a/tests/integration/contrib/aiohttp/test_aiohttp_project.py b/tests/integration/contrib/aiohttp/test_aiohttp_project.py index f7abfee3..9b1aee14 100644 --- a/tests/integration/contrib/aiohttp/test_aiohttp_project.py +++ b/tests/integration/contrib/aiohttp/test_aiohttp_project.py @@ -38,10 +38,6 @@ def api_key_encoded(self): class TestPetPhotoView(BaseTestPetstore): - @pytest.mark.xfail( - reason="response binary format not supported", - strict=True, - ) async def test_get_valid(self, client, data_gif): headers = { "Authorization": "Basic testuser",