diff --git a/modules/openapi-generator/src/main/resources/python-legacy/api.mustache b/modules/openapi-generator/src/main/resources/python-legacy/api.mustache index 723033609f98..cea2c7c66396 100644 --- a/modules/openapi-generator/src/main/resources/python-legacy/api.mustache +++ b/modules/openapi-generator/src/main/resources/python-legacy/api.mustache @@ -250,10 +250,12 @@ class {{classname}}(object): {{/hasProduces}} {{#hasConsumes}} # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}], '{{httpMethod}}', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list {{/hasConsumes}} # Authentication setting diff --git a/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache b/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache index 0bd333302623..d5b8a6f2548a 100644 --- a/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python-legacy/api_client.mustache @@ -554,7 +554,7 @@ class ApiClient(object): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] 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 39f33aee0b39..15c95fabb04e 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -594,7 +594,7 @@ class ApiClient(object): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] @@ -863,10 +863,11 @@ class Endpoint(object): content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: if params['body'] != "": - header_list = self.api_client.select_header_content_type( + content_types_list = self.api_client.select_header_content_type( content_type_headers_list, self.settings['http_method'], params['body']) - params['header']['Content-Type'] = header_list + if content_types_list: + params['header']['Content-Type'] = content_types_list return self.api_client.call_api( self.settings['endpoint_path'], self.settings['http_method'], diff --git a/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py b/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py index 17c46b6ac4c1..9f56ecf401d5 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py @@ -151,10 +151,12 @@ def call_123_test_special_tags_with_http_info(self, body, **kwargs): # noqa: E5 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/client/petstore/python-asyncio/petstore_api/api/fake_api.py b/samples/client/petstore/python-asyncio/petstore_api/api/fake_api.py index 44636a1a022d..24fe364a0bde 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api/fake_api.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api/fake_api.py @@ -147,10 +147,12 @@ def create_xml_item_with_http_info(self, xml_item, **kwargs): # noqa: E501 if 'xml_item' in local_var_params: body_params = local_var_params['xml_item'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -821,10 +823,12 @@ def test_body_with_file_schema_with_http_info(self, body, **kwargs): # noqa: E5 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -968,10 +972,12 @@ def test_body_with_query_params_with_http_info(self, query, body, **kwargs): # if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1110,10 +1116,12 @@ def test_client_model_with_http_info(self, body, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1381,10 +1389,12 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['http_basic_test'] # noqa: E501 @@ -1567,10 +1577,12 @@ def test_enum_parameters_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1878,10 +1890,12 @@ def test_inline_additional_properties_with_http_info(self, param, **kwargs): # if 'param' in local_var_params: body_params = local_var_params['param'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -2025,10 +2039,12 @@ def test_json_form_data_with_http_info(self, param, param2, **kwargs): # noqa: body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py index b5cd8cd22c94..9934eee07539 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api/fake_classname_tags123_api.py @@ -151,10 +151,12 @@ def test_classname_with_http_info(self, body, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['api_key_query'] # noqa: E501 diff --git a/samples/client/petstore/python-asyncio/petstore_api/api/pet_api.py b/samples/client/petstore/python-asyncio/petstore_api/api/pet_api.py index 59c3b238c1c8..da2a084682b1 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api/pet_api.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api/pet_api.py @@ -145,10 +145,12 @@ def add_pet_with_http_info(self, body, **kwargs): # noqa: E501 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -838,10 +840,12 @@ def update_pet_with_http_info(self, body, **kwargs): # noqa: E501 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -988,10 +992,12 @@ def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1142,10 +1148,12 @@ def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1302,10 +1310,12 @@ def upload_file_with_required_file_with_http_info(self, pet_id, required_file, * ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 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 122a18d0cab7..6bdc318161fd 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api_client.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api_client.py @@ -531,7 +531,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] diff --git a/samples/client/petstore/python-legacy/petstore_api/api/another_fake_api.py b/samples/client/petstore/python-legacy/petstore_api/api/another_fake_api.py index 17c46b6ac4c1..9f56ecf401d5 100644 --- a/samples/client/petstore/python-legacy/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python-legacy/petstore_api/api/another_fake_api.py @@ -151,10 +151,12 @@ def call_123_test_special_tags_with_http_info(self, body, **kwargs): # noqa: E5 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/client/petstore/python-legacy/petstore_api/api/fake_api.py b/samples/client/petstore/python-legacy/petstore_api/api/fake_api.py index 44636a1a022d..24fe364a0bde 100644 --- a/samples/client/petstore/python-legacy/petstore_api/api/fake_api.py +++ b/samples/client/petstore/python-legacy/petstore_api/api/fake_api.py @@ -147,10 +147,12 @@ def create_xml_item_with_http_info(self, xml_item, **kwargs): # noqa: E501 if 'xml_item' in local_var_params: body_params = local_var_params['xml_item'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -821,10 +823,12 @@ def test_body_with_file_schema_with_http_info(self, body, **kwargs): # noqa: E5 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -968,10 +972,12 @@ def test_body_with_query_params_with_http_info(self, query, body, **kwargs): # if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1110,10 +1116,12 @@ def test_client_model_with_http_info(self, body, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1381,10 +1389,12 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['http_basic_test'] # noqa: E501 @@ -1567,10 +1577,12 @@ def test_enum_parameters_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1878,10 +1890,12 @@ def test_inline_additional_properties_with_http_info(self, param, **kwargs): # if 'param' in local_var_params: body_params = local_var_params['param'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -2025,10 +2039,12 @@ def test_json_form_data_with_http_info(self, param, param2, **kwargs): # noqa: body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py index b5cd8cd22c94..9934eee07539 100644 --- a/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py @@ -151,10 +151,12 @@ def test_classname_with_http_info(self, body, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['api_key_query'] # noqa: E501 diff --git a/samples/client/petstore/python-legacy/petstore_api/api/pet_api.py b/samples/client/petstore/python-legacy/petstore_api/api/pet_api.py index 59c3b238c1c8..da2a084682b1 100644 --- a/samples/client/petstore/python-legacy/petstore_api/api/pet_api.py +++ b/samples/client/petstore/python-legacy/petstore_api/api/pet_api.py @@ -145,10 +145,12 @@ def add_pet_with_http_info(self, body, **kwargs): # noqa: E501 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -838,10 +840,12 @@ def update_pet_with_http_info(self, body, **kwargs): # noqa: E501 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -988,10 +992,12 @@ def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1142,10 +1148,12 @@ def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1302,10 +1310,12 @@ def upload_file_with_required_file_with_http_info(self, pet_id, required_file, * ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 diff --git a/samples/client/petstore/python-legacy/petstore_api/api_client.py b/samples/client/petstore/python-legacy/petstore_api/api_client.py index 15464e6282be..072c932db7ef 100644 --- a/samples/client/petstore/python-legacy/petstore_api/api_client.py +++ b/samples/client/petstore/python-legacy/petstore_api/api_client.py @@ -530,7 +530,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] diff --git a/samples/client/petstore/python-legacy/tests/test_api_client.py b/samples/client/petstore/python-legacy/tests/test_api_client.py index 8da54be7ae7a..9baa62120e16 100644 --- a/samples/client/petstore/python-legacy/tests/test_api_client.py +++ b/samples/client/petstore/python-legacy/tests/test_api_client.py @@ -96,7 +96,7 @@ def test_select_header_content_type(self): content_types = [] content_type = self.api_client.select_header_content_type(content_types) - self.assertEqual(content_type, 'application/json') + self.assertEqual(content_type, None) content_types = ['application/json-patch+json', 'application/json'] content_type = self.api_client.select_header_content_type(content_types, diff --git a/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py b/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py index 17c46b6ac4c1..9f56ecf401d5 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py @@ -151,10 +151,12 @@ def call_123_test_special_tags_with_http_info(self, body, **kwargs): # noqa: E5 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/client/petstore/python-tornado/petstore_api/api/fake_api.py b/samples/client/petstore/python-tornado/petstore_api/api/fake_api.py index 44636a1a022d..24fe364a0bde 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api/fake_api.py +++ b/samples/client/petstore/python-tornado/petstore_api/api/fake_api.py @@ -147,10 +147,12 @@ def create_xml_item_with_http_info(self, xml_item, **kwargs): # noqa: E501 if 'xml_item' in local_var_params: body_params = local_var_params['xml_item'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -821,10 +823,12 @@ def test_body_with_file_schema_with_http_info(self, body, **kwargs): # noqa: E5 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -968,10 +972,12 @@ def test_body_with_query_params_with_http_info(self, query, body, **kwargs): # if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1110,10 +1116,12 @@ def test_client_model_with_http_info(self, body, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1381,10 +1389,12 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['http_basic_test'] # noqa: E501 @@ -1567,10 +1577,12 @@ def test_enum_parameters_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1878,10 +1890,12 @@ def test_inline_additional_properties_with_http_info(self, param, **kwargs): # if 'param' in local_var_params: body_params = local_var_params['param'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -2025,10 +2039,12 @@ def test_json_form_data_with_http_info(self, param, param2, **kwargs): # noqa: body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py b/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py index b5cd8cd22c94..9934eee07539 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/client/petstore/python-tornado/petstore_api/api/fake_classname_tags123_api.py @@ -151,10 +151,12 @@ def test_classname_with_http_info(self, body, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['api_key_query'] # noqa: E501 diff --git a/samples/client/petstore/python-tornado/petstore_api/api/pet_api.py b/samples/client/petstore/python-tornado/petstore_api/api/pet_api.py index 59c3b238c1c8..da2a084682b1 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api/pet_api.py +++ b/samples/client/petstore/python-tornado/petstore_api/api/pet_api.py @@ -145,10 +145,12 @@ def add_pet_with_http_info(self, body, **kwargs): # noqa: E501 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -838,10 +840,12 @@ def update_pet_with_http_info(self, body, **kwargs): # noqa: E501 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -988,10 +992,12 @@ def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1142,10 +1148,12 @@ def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1302,10 +1310,12 @@ def upload_file_with_required_file_with_http_info(self, pet_id, required_file, * ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 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 5a833ebd1c0d..714686f8d6be 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api_client.py +++ b/samples/client/petstore/python-tornado/petstore_api/api_client.py @@ -532,7 +532,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index 664cf1c917b7..da37b066d3a3 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -582,7 +582,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] @@ -842,10 +842,11 @@ def call_with_http_info(self, **kwargs): content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: if params['body'] != "": - header_list = self.api_client.select_header_content_type( + content_types_list = self.api_client.select_header_content_type( content_type_headers_list, self.settings['http_method'], params['body']) - params['header']['Content-Type'] = header_list + if content_types_list: + params['header']['Content-Type'] = content_types_list return self.api_client.call_api( self.settings['endpoint_path'], self.settings['http_method'], diff --git a/samples/client/petstore/python/tests/test_api_client.py b/samples/client/petstore/python/tests/test_api_client.py index 35747c842173..5142a14e0dbb 100644 --- a/samples/client/petstore/python/tests/test_api_client.py +++ b/samples/client/petstore/python/tests/test_api_client.py @@ -120,7 +120,7 @@ def test_select_header_content_type(self): content_types = [] content_type = self.api_client.select_header_content_type(content_types) - self.assertEqual(content_type, 'application/json') + self.assertEqual(content_type, None) content_types = ['application/json-patch+json', 'application/json'] content_type = self.api_client.select_header_content_type(content_types, diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py index 664cf1c917b7..da37b066d3a3 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py @@ -582,7 +582,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] @@ -842,10 +842,11 @@ def call_with_http_info(self, **kwargs): content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: if params['body'] != "": - header_list = self.api_client.select_header_content_type( + content_types_list = self.api_client.select_header_content_type( content_type_headers_list, self.settings['http_method'], params['body']) - params['header']['Content-Type'] = header_list + if content_types_list: + params['header']['Content-Type'] = content_types_list return self.api_client.call_api( self.settings['endpoint_path'], self.settings['http_method'], diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py index c249bf1fc5e8..f808905993c4 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py @@ -120,7 +120,7 @@ def test_select_header_content_type(self): content_types = [] content_type = self.api_client.select_header_content_type(content_types) - self.assertEqual(content_type, 'application/json') + self.assertEqual(content_type, None) def test_sanitize_for_serialization(self): # None diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/api_client.py b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/api_client.py index e77be7a5319d..fbbd2aa4f120 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/api_client.py +++ b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/api_client.py @@ -582,7 +582,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] @@ -842,10 +842,11 @@ def call_with_http_info(self, **kwargs): content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: if params['body'] != "": - header_list = self.api_client.select_header_content_type( + content_types_list = self.api_client.select_header_content_type( content_type_headers_list, self.settings['http_method'], params['body']) - params['header']['Content-Type'] = header_list + if content_types_list: + params['header']['Content-Type'] = content_types_list return self.api_client.call_api( self.settings['endpoint_path'], self.settings['http_method'], diff --git a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py index e38f7442f7bf..3aaf2a296f00 100644 --- a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py +++ b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py @@ -582,7 +582,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] @@ -842,10 +842,11 @@ def call_with_http_info(self, **kwargs): content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: if params['body'] != "": - header_list = self.api_client.select_header_content_type( + content_types_list = self.api_client.select_header_content_type( content_type_headers_list, self.settings['http_method'], params['body']) - params['header']['Content-Type'] = header_list + if content_types_list: + params['header']['Content-Type'] = content_types_list return self.api_client.call_api( self.settings['endpoint_path'], self.settings['http_method'], diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/another_fake_api.py index bbebcdf743f1..4d184e6420f6 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/another_fake_api.py @@ -151,10 +151,12 @@ def call_123_test_special_tags_with_http_info(self, client, **kwargs): # noqa: ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py index fb9e0b370c14..4bb39adf2914 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_api.py @@ -284,10 +284,12 @@ def fake_http_signature_test_with_http_info(self, pet, **kwargs): # noqa: E501 if 'pet' in local_var_params: body_params = local_var_params['pet'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['http_signature_test'] # noqa: E501 @@ -422,10 +424,12 @@ def fake_outer_boolean_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -562,10 +566,12 @@ def fake_outer_composite_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -702,10 +708,12 @@ def fake_outer_number_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -842,10 +850,12 @@ def fake_outer_string_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -986,10 +996,12 @@ def fake_property_enum_integer_serialize_with_http_info(self, outer_object_with_ ['*/*']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1122,10 +1134,12 @@ def test_body_with_binary_with_http_info(self, body, **kwargs): # noqa: E501 if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['image/png'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1260,10 +1274,12 @@ def test_body_with_file_schema_with_http_info(self, file_schema_test_class, **kw if 'file_schema_test_class' in local_var_params: body_params = local_var_params['file_schema_test_class'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1407,10 +1423,12 @@ def test_body_with_query_params_with_http_info(self, query, user, **kwargs): # if 'user' in local_var_params: body_params = local_var_params['user'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1549,10 +1567,12 @@ def test_client_model_with_http_info(self, client, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1820,10 +1840,12 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['http_basic_test'] # noqa: E501 @@ -2006,10 +2028,12 @@ def test_enum_parameters_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -2319,10 +2343,12 @@ def test_inline_additional_properties_with_http_info(self, request_body, **kwarg if 'request_body' in local_var_params: body_params = local_var_params['request_body'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -2468,10 +2494,12 @@ def test_json_form_data_with_http_info(self, param, param2, **kwargs): # noqa: body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'GET', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py index 05c1c8a0e4ff..db8bff321615 100644 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/fake_classname_tags123_api.py @@ -151,10 +151,12 @@ def test_classname_with_http_info(self, client, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PATCH', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['api_key_query'] # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/pet_api.py index fe2827a9f675..cf546a00625f 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/pet_api.py @@ -160,10 +160,12 @@ def add_pet_with_http_info(self, pet, **kwargs): # noqa: E501 if 'pet' in local_var_params: body_params = local_var_params['pet'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -871,10 +873,12 @@ def update_pet_with_http_info(self, pet, **kwargs): # noqa: E501 if 'pet' in local_var_params: body_params = local_var_params['pet'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json', 'application/xml'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1024,10 +1028,12 @@ def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/x-www-form-urlencoded'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1180,10 +1186,12 @@ def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1342,10 +1350,12 @@ def upload_file_with_required_file_with_http_info(self, pet_id, required_file, * ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['multipart/form-data'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/store_api.py index c46b770c8244..d66190ccbc64 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/store_api.py @@ -554,10 +554,12 @@ def place_order_with_http_info(self, order, **kwargs): # noqa: E501 ['application/xml', 'application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/user_api.py index 996d60a99141..1dc9860baf48 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api/user_api.py @@ -147,10 +147,12 @@ def create_user_with_http_info(self, user, **kwargs): # noqa: E501 if 'user' in local_var_params: body_params = local_var_params['user'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -285,10 +287,12 @@ def create_users_with_array_input_with_http_info(self, user, **kwargs): # noqa: if 'user' in local_var_params: body_params = local_var_params['user'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -423,10 +427,12 @@ def create_users_with_list_input_with_http_info(self, user, **kwargs): # noqa: if 'user' in local_var_params: body_params = local_var_params['user'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'POST', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1115,10 +1121,12 @@ def update_user_with_http_info(self, username, user, **kwargs): # noqa: E501 if 'user' in local_var_params: body_params = local_var_params['user'] # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', + content_types_list = local_var_params.get('_content_type', self.api_client.select_header_content_type( ['application/json'], 'PUT', body_params)) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py index 15464e6282be..072c932db7ef 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/api_client.py @@ -530,7 +530,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] 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 f29efaa1ce14..c5e0b7ffeb65 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -582,7 +582,7 @@ def select_header_content_type(self, content_types, method=None, body=None): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return None content_types = [x.lower() for x in content_types] @@ -849,10 +849,11 @@ def call_with_http_info(self, **kwargs): content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: if params['body'] != "": - header_list = self.api_client.select_header_content_type( + content_types_list = self.api_client.select_header_content_type( content_type_headers_list, self.settings['http_method'], params['body']) - params['header']['Content-Type'] = header_list + if content_types_list: + params['header']['Content-Type'] = content_types_list return self.api_client.call_api( self.settings['endpoint_path'], self.settings['http_method'],