mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-05 02:56:11 +00:00
[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:
@@ -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'],
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user