From 0f836b9265dfb460e1d8f8de112033f0da774286 Mon Sep 17 00:00:00 2001 From: p1c2u Date: Wed, 20 Sep 2023 19:06:20 +0000 Subject: [PATCH] aiohttp response binary format support --- openapi_core/contrib/aiohttp/responses.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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