From b3bc926b1d48840903a1293b0c74c49e9391966c Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Wed, 4 Nov 2020 17:41:00 +0100 Subject: [PATCH] [python] check output content-type only if preload_content is set (#7847) --- .../src/main/resources/python/api_client.mustache | 3 +-- .../client/petstore/python-asyncio/petstore_api/api_client.py | 3 +-- .../client/petstore/python-tornado/petstore_api/api_client.py | 3 +-- samples/client/petstore/python/petstore_api/api_client.py | 3 +-- .../openapi3/client/petstore/python/petstore_api/api_client.py | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index a3e6eba30dc..4f230dff623 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -200,8 +200,6 @@ class ApiClient(object): e.body = e.body.decode('utf-8') if six.PY3 else e.body raise e - content_type = response_data.getheader('content-type') - self.last_response = response_data return_data = response_data @@ -218,6 +216,7 @@ class ApiClient(object): if six.PY3 and response_type not in ["file", "bytes"]: match = None + content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) encoding = match.group(1) if match else "utf-8" diff --git a/samples/client/petstore/python-asyncio/petstore_api/api_client.py b/samples/client/petstore/python-asyncio/petstore_api/api_client.py index eb20aa8e88d..14d998d1673 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api_client.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api_client.py @@ -191,8 +191,6 @@ class ApiClient(object): e.body = e.body.decode('utf-8') if six.PY3 else e.body raise e - content_type = response_data.getheader('content-type') - self.last_response = response_data return_data = response_data @@ -204,6 +202,7 @@ class ApiClient(object): if six.PY3 and response_type not in ["file", "bytes"]: match = None + content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) encoding = match.group(1) if match else "utf-8" diff --git a/samples/client/petstore/python-tornado/petstore_api/api_client.py b/samples/client/petstore/python-tornado/petstore_api/api_client.py index 4a309c6ae9e..a8778557f97 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api_client.py +++ b/samples/client/petstore/python-tornado/petstore_api/api_client.py @@ -192,8 +192,6 @@ class ApiClient(object): e.body = e.body.decode('utf-8') if six.PY3 else e.body raise e - content_type = response_data.getheader('content-type') - self.last_response = response_data return_data = response_data @@ -205,6 +203,7 @@ class ApiClient(object): if six.PY3 and response_type not in ["file", "bytes"]: match = None + content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) encoding = match.group(1) if match else "utf-8" diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index afaf1427d31..52c58e68a08 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -190,8 +190,6 @@ class ApiClient(object): e.body = e.body.decode('utf-8') if six.PY3 else e.body raise e - content_type = response_data.getheader('content-type') - self.last_response = response_data return_data = response_data @@ -203,6 +201,7 @@ class ApiClient(object): if six.PY3 and response_type not in ["file", "bytes"]: match = None + content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) encoding = match.group(1) if match else "utf-8" diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index afaf1427d31..52c58e68a08 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -190,8 +190,6 @@ class ApiClient(object): e.body = e.body.decode('utf-8') if six.PY3 else e.body raise e - content_type = response_data.getheader('content-type') - self.last_response = response_data return_data = response_data @@ -203,6 +201,7 @@ class ApiClient(object): if six.PY3 and response_type not in ["file", "bytes"]: match = None + content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) encoding = match.group(1) if match else "utf-8"