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 723033609f9..cea2c7c6639 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 0bd33330262..d5b8a6f2548 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 39f33aee0b3..15c95fabb04 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 17c46b6ac4c..9f56ecf401d 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 @@ class AnotherFakeApi(object): ['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 44636a1a022..24fe364a0bd 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): ['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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 b5cd8cd22c9..9934eee0753 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 @@ class FakeClassnameTags123Api(object): ['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 59c3b238c1c..da2a084682b 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): ['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 @@ class PetApi(object): ['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 122a18d0cab..6bdc318161f 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 @@ 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/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 17c46b6ac4c..9f56ecf401d 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 @@ class AnotherFakeApi(object): ['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 44636a1a022..24fe364a0bd 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): ['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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 b5cd8cd22c9..9934eee0753 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 @@ class FakeClassnameTags123Api(object): ['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 59c3b238c1c..da2a084682b 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): ['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 @@ class PetApi(object): ['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 15464e6282b..072c932db7e 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 @@ 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/samples/client/petstore/python-legacy/tests/test_api_client.py b/samples/client/petstore/python-legacy/tests/test_api_client.py index 8da54be7ae7..9baa62120e1 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 @@ class ApiClientTests(unittest.TestCase): 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 17c46b6ac4c..9f56ecf401d 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 @@ class AnotherFakeApi(object): ['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 44636a1a022..24fe364a0bd 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): ['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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 b5cd8cd22c9..9934eee0753 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 @@ class FakeClassnameTags123Api(object): ['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 59c3b238c1c..da2a084682b 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): ['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 @@ class PetApi(object): ['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 5a833ebd1c0..714686f8d6b 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 @@ 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/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index 664cf1c917b..da37b066d3a 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 @@ 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] @@ -842,10 +842,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/tests/test_api_client.py b/samples/client/petstore/python/tests/test_api_client.py index 35747c84217..5142a14e0db 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 @@ class ApiClientTests(unittest.TestCase): 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 664cf1c917b..da37b066d3a 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 @@ 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] @@ -842,10 +842,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_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/tests/test_api_client.py index c249bf1fc5e..f808905993c 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 @@ class ApiClientTests(unittest.TestCase): 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 e77be7a5319..fbbd2aa4f12 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 @@ 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] @@ -842,10 +842,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/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 e38f7442f7b..3aaf2a296f0 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 @@ 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] @@ -842,10 +842,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/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 bbebcdf743f..4d184e6420f 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 @@ class AnotherFakeApi(object): ['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 fb9e0b370c1..4bb39adf291 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): ['*/*']) # 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 @@ class FakeApi(object): ['*/*']) # 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 @@ class FakeApi(object): ['*/*']) # 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 @@ class FakeApi(object): ['*/*']) # 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 @@ class FakeApi(object): ['*/*']) # 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): ['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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 @@ class FakeApi(object): 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 05c1c8a0e4f..db8bff32161 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 @@ class FakeClassnameTags123Api(object): ['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 fe2827a9f67..cf546a00625 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): ['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 @@ class PetApi(object): ['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 c46b770c824..d66190ccbc6 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 @@ class StoreApi(object): ['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 996d60a9914..1dc9860baf4 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 15464e6282b..072c932db7e 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 @@ 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/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index f29efaa1ce1..c5e0b7ffeb6 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 @@ 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] @@ -849,10 +849,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'],