From cfe9482be600cec9e3a35315d16d9347aa793eb6 Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 03:57:33 +0000 Subject: [PATCH 01/11] remove default content-type in the request --- .../src/main/resources/python-legacy/api.mustache | 9 +++++---- .../main/resources/python-legacy/api_client.mustache | 2 +- .../src/main/resources/python/api_client.mustache | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) 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..ac26c31165d4 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,11 @@ class {{classname}}(object): {{/hasProduces}} {{#hasConsumes}} # HTTP header `Content-Type` - header_params['Content-Type'] = local_var_params.get('_content_type', - self.api_client.select_header_content_type( - [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}], - '{{httpMethod}}', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) # noqa: E501 + [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) # 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..774db6cc0741 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,10 @@ 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_type_headers_list, self.settings['http_method'], - params['body']) - params['header']['Content-Type'] = header_list + content_types_list = self.api_client.select_header_content_type( + content_type_headers_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'], From 90927af3c66b266cad83cbbdd4fae9f5c96a930f Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 03:59:39 +0000 Subject: [PATCH 02/11] add remove default content-type test --- samples/client/petstore/python-legacy/tests/test_api_client.py | 2 +- samples/client/petstore/python/tests/test_api_client.py | 2 +- .../tests/test_api_client.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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/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 From ff6aac1010de1b226da5767ce7d0e43c7f1612e1 Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:13:43 +0000 Subject: [PATCH 03/11] fix duplicate content type --- .../src/main/resources/python-legacy/api.mustache | 1 - 1 file changed, 1 deletion(-) 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 ac26c31165d4..814d2a8776b7 100644 --- a/modules/openapi-generator/src/main/resources/python-legacy/api.mustache +++ b/modules/openapi-generator/src/main/resources/python-legacy/api.mustache @@ -252,7 +252,6 @@ class {{classname}}(object): # HTTP header `Content-Type` content_types_list = self.api_client.select_header_content_type( # noqa: E501 [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) # noqa: E501 - [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) # noqa: E501 if content_types_list: header_params['Content-Type'] = content_types_list From 65c8aaeed9cd9560433c05bb25d26cb42caaf338 Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:14:53 +0000 Subject: [PATCH 04/11] update sample --- .../petstore_api/api/another_fake_api.py | 8 +- .../petstore_api/api/fake_api.py | 112 +++++++++--------- .../api/fake_classname_tags123_api.py | 8 +- .../python-legacy/petstore_api/api/pet_api.py | 40 +++---- .../petstore_api/api/store_api.py | 8 +- .../petstore_api/api/user_api.py | 32 ++--- .../python-legacy/petstore_api/api_client.py | 2 +- .../python/petstore_api/api_client.py | 10 +- 8 files changed, 110 insertions(+), 110 deletions(-) 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..8ebe4a88d93b 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,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'PATCH', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # 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..76f49bbe0cb3 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,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json', 'application/xml'], - 'GET', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json', 'application/xml']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['http_signature_test'] # noqa: E501 @@ -422,10 +422,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -562,10 +562,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -702,10 +702,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -842,10 +842,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -986,10 +986,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1122,10 +1122,10 @@ 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', - self.api_client.select_header_content_type( - ['image/png'], - 'PUT', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['image/png']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1260,10 +1260,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'PUT', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1407,10 +1407,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'PUT', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1549,10 +1549,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'PATCH', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1820,10 +1820,10 @@ 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', - self.api_client.select_header_content_type( - ['application/x-www-form-urlencoded'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/x-www-form-urlencoded']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['http_basic_test'] # noqa: E501 @@ -2006,10 +2006,10 @@ 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', - self.api_client.select_header_content_type( - ['application/x-www-form-urlencoded'], - 'GET', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/x-www-form-urlencoded']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -2319,10 +2319,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -2468,10 +2468,10 @@ 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', - self.api_client.select_header_content_type( - ['application/x-www-form-urlencoded'], - 'GET', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/x-www-form-urlencoded']) # 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..1b07cd660ae9 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,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'PATCH', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # 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..b4fa49b1b18f 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,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json', 'application/xml'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json', 'application/xml']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -871,10 +871,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json', 'application/xml'], - 'PUT', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json', 'application/xml']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1024,10 +1024,10 @@ 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', - self.api_client.select_header_content_type( - ['application/x-www-form-urlencoded'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/x-www-form-urlencoded']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1180,10 +1180,10 @@ 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', - self.api_client.select_header_content_type( - ['multipart/form-data'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['multipart/form-data']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 @@ -1342,10 +1342,10 @@ 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', - self.api_client.select_header_content_type( - ['multipart/form-data'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['multipart/form-data']) # 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..58e08c4f61f6 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,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # 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..6c85187f4ea8 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,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -285,10 +285,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -423,10 +423,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'POST', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + if content_types_list: + header_params['Content-Type'] = content_types_list # Authentication setting auth_settings = [] # noqa: E501 @@ -1115,10 +1115,10 @@ 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', - self.api_client.select_header_content_type( - ['application/json'], - 'PUT', body_params)) # noqa: E501 + content_types_list = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # 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..53daa7351b67 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,10 @@ 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_type_headers_list, self.settings['http_method'], - params['body']) - params['header']['Content-Type'] = header_list + content_types_list = self.api_client.select_header_content_type( + content_type_headers_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'], From 5d440ed22ea302ba14761226ba95e680e56d3bd0 Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:19:00 +0000 Subject: [PATCH 05/11] add missing params --- .../src/main/resources/python/api_client.mustache | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 774db6cc0741..e7a262b9f2f5 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -864,7 +864,9 @@ class Endpoint(object): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list) + content_type_headers_list, + self.settings['http_method'], + params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list From c4d707cddfbdb5afba65ceaed2cfa08acd2eb9cd Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:19:12 +0000 Subject: [PATCH 06/11] update sample --- .../client/petstore/python/petstore_api/api_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 53daa7351b67..2857c393c773 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -850,7 +850,9 @@ def call_with_http_info(self, **kwargs): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list) + content_type_headers_list, + self.settings['http_method'], + params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list From 537687a68746656cedec5656a7fdb28c443cc83c Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:26:41 +0000 Subject: [PATCH 07/11] only assign content type if exist --- .../src/main/resources/python-legacy/api.mustache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 814d2a8776b7..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,8 +250,10 @@ class {{classname}}(object): {{/hasProduces}} {{#hasConsumes}} # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]) # noqa: E501 + 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 From d94a83f4c374502fa0c688415215142fbacf95da Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:26:59 +0000 Subject: [PATCH 08/11] update sample --- .../petstore_api/api/another_fake_api.py | 6 +- .../petstore_api/api/fake_api.py | 84 ++++++++++++------- .../api/fake_classname_tags123_api.py | 6 +- .../python-legacy/petstore_api/api/pet_api.py | 30 ++++--- .../petstore_api/api/store_api.py | 6 +- .../petstore_api/api/user_api.py | 24 ++++-- 6 files changed, 104 insertions(+), 52 deletions(-) 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 8ebe4a88d93b..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,8 +151,10 @@ def call_123_test_special_tags_with_http_info(self, client, **kwargs): # noqa: ['application/json']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 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 76f49bbe0cb3..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,8 +284,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json', 'application/xml']) # noqa: E501 + 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 @@ -422,8 +424,10 @@ def fake_outer_boolean_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -562,8 +566,10 @@ def fake_outer_composite_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -702,8 +708,10 @@ def fake_outer_number_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -842,8 +850,10 @@ def fake_outer_string_serialize_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -986,8 +996,10 @@ def fake_property_enum_integer_serialize_with_http_info(self, outer_object_with_ ['*/*']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -1122,8 +1134,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['image/png']) # noqa: E501 + 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 @@ -1260,8 +1274,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -1407,8 +1423,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -1549,8 +1567,10 @@ def test_client_model_with_http_info(self, client, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -1820,8 +1840,10 @@ def test_endpoint_parameters_with_http_info(self, number, double, pattern_withou body_params = None # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 + 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 @@ -2006,8 +2028,10 @@ def test_enum_parameters_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 + 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 @@ -2319,8 +2343,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -2468,8 +2494,10 @@ def test_json_form_data_with_http_info(self, param, param2, **kwargs): # noqa: body_params = None # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 + 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 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 1b07cd660ae9..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,8 +151,10 @@ def test_classname_with_http_info(self, client, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 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 b4fa49b1b18f..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,8 +160,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json', 'application/xml']) # noqa: E501 + 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 @@ -871,8 +873,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json', 'application/xml']) # noqa: E501 + 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 @@ -1024,8 +1028,10 @@ def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501 body_params = None # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 + 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 @@ -1180,8 +1186,10 @@ def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['multipart/form-data']) # noqa: E501 + 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 @@ -1342,8 +1350,10 @@ def upload_file_with_required_file_with_http_info(self, pet_id, required_file, * ['application/json']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['multipart/form-data']) # noqa: E501 + 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 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 58e08c4f61f6..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,8 +554,10 @@ def place_order_with_http_info(self, order, **kwargs): # noqa: E501 ['application/xml', 'application/json']) # noqa: E501 # HTTP header `Content-Type` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 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 6c85187f4ea8..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,8 +147,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -285,8 +287,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -423,8 +427,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 @@ -1115,8 +1121,10 @@ 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` - content_types_list = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + 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 From 35fe9a3a4f000ff3b619f1bce74d9c021c9eaeb6 Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:28:30 +0000 Subject: [PATCH 09/11] update sample --- .../petstore_api/api/another_fake_api.py | 4 ++- .../petstore_api/api/fake_api.py | 32 ++++++++++++++----- .../api/fake_classname_tags123_api.py | 4 ++- .../petstore_api/api/pet_api.py | 20 +++++++++--- .../python-asyncio/petstore_api/api_client.py | 2 +- .../petstore_api/api/another_fake_api.py | 4 ++- .../petstore_api/api/fake_api.py | 32 ++++++++++++++----- .../api/fake_classname_tags123_api.py | 4 ++- .../python-legacy/petstore_api/api/pet_api.py | 20 +++++++++--- .../python-legacy/petstore_api/api_client.py | 2 +- .../petstore_api/api/another_fake_api.py | 4 ++- .../petstore_api/api/fake_api.py | 32 ++++++++++++++----- .../api/fake_classname_tags123_api.py | 4 ++- .../petstore_api/api/pet_api.py | 20 +++++++++--- .../python-tornado/petstore_api/api_client.py | 2 +- .../python/petstore_api/api_client.py | 10 +++--- .../petstore_api/api_client.py | 10 +++--- .../python/x_auth_id_alias/api_client.py | 10 +++--- .../python/dynamic_servers/api_client.py | 10 +++--- 19 files changed, 162 insertions(+), 64 deletions(-) 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-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..1be873679e56 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,12 @@ 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_type_headers_list, self.settings['http_method'], + 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/petstore_api/api_client.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py index 664cf1c917b7..1be873679e56 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,12 @@ 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_type_headers_list, self.settings['http_method'], + 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/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..7cfd91103c6b 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,12 @@ 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_type_headers_list, self.settings['http_method'], + 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..d1ece085015f 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,12 @@ 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_type_headers_list, self.settings['http_method'], + 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'], From cef7579cc334467060f25fe3bd8d04b32cce2b64 Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:39:48 +0000 Subject: [PATCH 10/11] format code --- .../src/main/resources/python/api_client.mustache | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index e7a262b9f2f5..15c95fabb04e 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -864,8 +864,7 @@ class Endpoint(object): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list, - self.settings['http_method'], + content_type_headers_list, self.settings['http_method'], params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list From 5d9970a430b0657e74d62ff3a5b75b06989d75b9 Mon Sep 17 00:00:00 2001 From: Kuan-Yin Chen Date: Tue, 22 Feb 2022 04:40:28 +0000 Subject: [PATCH 11/11] update sample --- samples/client/petstore/python/petstore_api/api_client.py | 3 +-- .../petstore_api/api_client.py | 3 +-- .../x-auth-id-alias/python/x_auth_id_alias/api_client.py | 3 +-- .../dynamic-servers/python/dynamic_servers/api_client.py | 3 +-- .../openapi3/client/petstore/python/petstore_api/api_client.py | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index 1be873679e56..da37b066d3a3 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -843,8 +843,7 @@ def call_with_http_info(self, **kwargs): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list, - self.settings['http_method'], + content_type_headers_list, self.settings['http_method'], params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list 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 1be873679e56..da37b066d3a3 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/api_client.py @@ -843,8 +843,7 @@ def call_with_http_info(self, **kwargs): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list, - self.settings['http_method'], + content_type_headers_list, self.settings['http_method'], params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list 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 7cfd91103c6b..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 @@ -843,8 +843,7 @@ def call_with_http_info(self, **kwargs): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list, - self.settings['http_method'], + content_type_headers_list, self.settings['http_method'], params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list 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 d1ece085015f..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 @@ -843,8 +843,7 @@ def call_with_http_info(self, **kwargs): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list, - self.settings['http_method'], + content_type_headers_list, self.settings['http_method'], params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list 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 2857c393c773..c5e0b7ffeb65 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -850,8 +850,7 @@ def call_with_http_info(self, **kwargs): if content_type_headers_list: if params['body'] != "": content_types_list = self.api_client.select_header_content_type( - content_type_headers_list, - self.settings['http_method'], + content_type_headers_list, self.settings['http_method'], params['body']) if content_types_list: params['header']['Content-Type'] = content_types_list