mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
[python] json like str response (#18069)
* [python] json like str response * [python] fix response deserialize * [python] update sample * [python] fix echo_api test quotes
This commit is contained in:
@@ -313,7 +313,10 @@ class ApiClient:
|
||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
||||
encoding = match.group(1) if match else "utf-8"
|
||||
response_text = response_data.data.decode(encoding)
|
||||
return_data = self.deserialize(response_text, response_type)
|
||||
if response_type in ["bytearray", "str"]:
|
||||
return_data = self.__deserialize_primitive(response_text, response_type)
|
||||
else:
|
||||
return_data = self.deserialize(response_text, response_type)
|
||||
finally:
|
||||
if not 200 <= response_data.status <= 299:
|
||||
raise ApiException.from_response(
|
||||
|
||||
@@ -174,7 +174,7 @@ class TestManual(unittest.TestCase):
|
||||
n = openapi_client.Pet.from_dict({"name": "testing", "photoUrls": ["http://1", "http://2"]})
|
||||
api_instance = openapi_client.BodyApi()
|
||||
api_response = api_instance.test_echo_body_pet_response_string(n)
|
||||
self.assertEqual(api_response, "{'name': 'testing', 'photoUrls': ['http://1', 'http://2']}")
|
||||
self.assertEqual(api_response, '{"name": "testing", "photoUrls": ["http://1", "http://2"]}')
|
||||
|
||||
t = openapi_client.Tag()
|
||||
api_response = api_instance.test_echo_body_tag_response_string(t)
|
||||
|
||||
Reference in New Issue
Block a user