[Python] remove default content-type in the request (#10782)

* remove default content-type in the request

* add remove default content-type test

* fix duplicate content type

* update sample

* add missing params

* update sample

* only assign content type if exist

* update sample

* update sample

* format code

* update sample
This commit is contained in:
Kuan-Yin Chen 2022-02-23 22:08:49 -06:00 committed by GitHub
parent 7bda4734e6
commit ab63786610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 248 additions and 98 deletions

View File

@ -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

View File

@ -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]

View File

@ -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'],

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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'],

View File

@ -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,

View File

@ -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'],

View File

@ -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

View File

@ -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'],

View File

@ -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'],

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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'],