Skip to content

Commit 46c4477

Browse files
committed
aiohttp response binary format support
1 parent cbbe084 commit 46c4477

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

openapi_core/contrib/aiohttp/responses.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ def data(self) -> str:
1717
if self.response.body is None:
1818
return ""
1919
if isinstance(self.response.body, bytes):
20-
return self.response.body.decode("utf-8")
20+
try:
21+
return self.response.body.decode("utf-8")
22+
except UnicodeDecodeError:
23+
return self.response.body
2124
assert isinstance(self.response.body, str)
2225
return self.response.body
2326

tests/integration/contrib/aiohttp/test_aiohttp_project.py

-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ def api_key_encoded(self):
3838

3939

4040
class TestPetPhotoView(BaseTestPetstore):
41-
@pytest.mark.xfail(
42-
reason="response binary format not supported",
43-
strict=True,
44-
)
4541
async def test_get_valid(self, client, data_gif):
4642
headers = {
4743
"Authorization": "Basic testuser",

0 commit comments

Comments
 (0)