forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 6.0.x
This commit is contained in:
@@ -198,6 +198,9 @@ class UsageApi(object):
|
||||
_check_return_type (bool): specifies if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
_content_type (str/None): force body content-type.
|
||||
Default is None and content-type will be predicted by allowed
|
||||
content-types and body.
|
||||
_host_index (int/None): specifies the index of the server
|
||||
that we want to use.
|
||||
Default is read from the configuration.
|
||||
@@ -226,6 +229,8 @@ class UsageApi(object):
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_content_type'] = kwargs.get(
|
||||
'_content_type')
|
||||
kwargs['_host_index'] = kwargs.get('_host_index')
|
||||
return self.custom_server_endpoint.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -259,6 +264,9 @@ class UsageApi(object):
|
||||
_check_return_type (bool): specifies if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
_content_type (str/None): force body content-type.
|
||||
Default is None and content-type will be predicted by allowed
|
||||
content-types and body.
|
||||
_host_index (int/None): specifies the index of the server
|
||||
that we want to use.
|
||||
Default is read from the configuration.
|
||||
@@ -287,6 +295,8 @@ class UsageApi(object):
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_content_type'] = kwargs.get(
|
||||
'_content_type')
|
||||
kwargs['_host_index'] = kwargs.get('_host_index')
|
||||
return self.default_server_endpoint.call_with_http_info(**kwargs)
|
||||
|
||||
|
||||
@@ -131,7 +131,8 @@ class ApiClient(object):
|
||||
_preload_content: bool = True,
|
||||
_request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None,
|
||||
_host: typing.Optional[str] = None,
|
||||
_check_type: typing.Optional[bool] = None
|
||||
_check_type: typing.Optional[bool] = None,
|
||||
_content_type: typing.Optional[str] = None
|
||||
):
|
||||
|
||||
config = self.configuration
|
||||
@@ -572,10 +573,12 @@ class ApiClient(object):
|
||||
else:
|
||||
return ', '.join(accepts)
|
||||
|
||||
def select_header_content_type(self, content_types):
|
||||
def select_header_content_type(self, content_types, method=None, body=None):
|
||||
"""Returns `Content-Type` based on an array of content_types provided.
|
||||
|
||||
:param content_types: List of content-types.
|
||||
:param method: http method (e.g. POST, PATCH).
|
||||
:param body: http body to send.
|
||||
:return: Content-Type (e.g. application/json).
|
||||
"""
|
||||
if not content_types:
|
||||
@@ -583,6 +586,11 @@ class ApiClient(object):
|
||||
|
||||
content_types = [x.lower() for x in content_types]
|
||||
|
||||
if (method == 'PATCH' and
|
||||
'application/json-patch+json' in content_types and
|
||||
isinstance(body, list)):
|
||||
return 'application/json-patch+json'
|
||||
|
||||
if 'application/json' in content_types or '*/*' in content_types:
|
||||
return 'application/json'
|
||||
else:
|
||||
@@ -664,7 +672,8 @@ class Endpoint(object):
|
||||
'_request_timeout',
|
||||
'_return_http_data_only',
|
||||
'_check_input_type',
|
||||
'_check_return_type'
|
||||
'_check_return_type',
|
||||
'_content_type'
|
||||
])
|
||||
self.params_map['nullable'].extend(['_request_timeout'])
|
||||
self.validations = root_map['validations']
|
||||
@@ -677,7 +686,8 @@ class Endpoint(object):
|
||||
'_request_timeout': (none_type, float, (float,), [float], int, (int,), [int]),
|
||||
'_return_http_data_only': (bool,),
|
||||
'_check_input_type': (bool,),
|
||||
'_check_return_type': (bool,)
|
||||
'_check_return_type': (bool,),
|
||||
'_content_type': (none_type, str)
|
||||
}
|
||||
self.openapi_types.update(extra_types)
|
||||
self.attribute_map = root_map['attribute_map']
|
||||
@@ -824,12 +834,16 @@ class Endpoint(object):
|
||||
params['header']['Accept'] = self.api_client.select_header_accept(
|
||||
accept_headers_list)
|
||||
|
||||
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)
|
||||
params['header']['Content-Type'] = header_list
|
||||
if kwargs.get('_content_type'):
|
||||
params['header']['Content-Type'] = kwargs['_content_type']
|
||||
else:
|
||||
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
|
||||
|
||||
return self.api_client.call_api(
|
||||
self.settings['endpoint_path'], self.settings['http_method'],
|
||||
|
||||
Reference in New Issue
Block a user