forked from loafle/openapi-generator-original
Python collection formatting fixes/support (#3697)
* python: Rework form data collection formatting support * python: Add/fix support for query string collection formatting * python: Add/fix support for path collection formatting * python: Add/fix support for header collection formatting
This commit is contained in:
parent
b909252bb8
commit
c43286c569
@ -140,30 +140,37 @@ class {{classname}}(object):
|
||||
{{/pattern}}
|
||||
{{/hasValidation}}
|
||||
{{/allParams}}
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '{{path}}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
{{#pathParams}}
|
||||
if '{{paramName}}' in params:
|
||||
path_params['{{baseName}}'] = params['{{paramName}}']
|
||||
path_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}}
|
||||
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}}
|
||||
{{/pathParams}}
|
||||
|
||||
query_params = {}
|
||||
{{#queryParams}}
|
||||
if '{{paramName}}' in params:
|
||||
query_params['{{baseName}}'] = params['{{paramName}}']
|
||||
query_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}}
|
||||
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}}
|
||||
{{/queryParams}}
|
||||
|
||||
header_params = {}
|
||||
{{#headerParams}}
|
||||
if '{{paramName}}' in params:
|
||||
header_params['{{baseName}}'] = params['{{paramName}}']
|
||||
header_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}}
|
||||
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}}
|
||||
{{/headerParams}}
|
||||
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
{{#formParams}}
|
||||
if '{{paramName}}' in params:
|
||||
{{#notFile}}form_params.extend(self.api_client.parameter_to_tuples('{{collectionFormat}}', '{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}
|
||||
{{#notFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}}
|
||||
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}}
|
||||
{{/formParams}}
|
||||
|
||||
body_params = None
|
||||
@ -195,6 +202,7 @@ class {{classname}}(object):
|
||||
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}},
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
@ -95,7 +95,8 @@ class ApiClient(object):
|
||||
def __call_api(self, resource_path, method,
|
||||
path_params=None, query_params=None, header_params=None,
|
||||
body=None, post_params=None, files=None,
|
||||
response_type=None, auth_settings=None, callback=None, _return_http_data_only=None):
|
||||
response_type=None, auth_settings=None, callback=None,
|
||||
_return_http_data_only=None, collection_formats=None):
|
||||
|
||||
# header parameters
|
||||
header_params = header_params or {}
|
||||
@ -104,25 +105,30 @@ class ApiClient(object):
|
||||
header_params['Cookie'] = self.cookie
|
||||
if header_params:
|
||||
header_params = self.sanitize_for_serialization(header_params)
|
||||
header_params = dict(self.parameters_to_tuples(header_params,
|
||||
collection_formats))
|
||||
|
||||
# path parameters
|
||||
if path_params:
|
||||
path_params = self.sanitize_for_serialization(path_params)
|
||||
for k, v in iteritems(path_params):
|
||||
replacement = quote(str(self.to_path_value(v)))
|
||||
resource_path = resource_path.\
|
||||
replace('{' + k + '}', replacement)
|
||||
path_params = self.parameters_to_tuples(path_params,
|
||||
collection_formats)
|
||||
for k, v in path_params:
|
||||
resource_path = resource_path.replace(
|
||||
'{%s}' % k, quote(str(v)))
|
||||
|
||||
# query parameters
|
||||
if query_params:
|
||||
query_params = self.sanitize_for_serialization(query_params)
|
||||
query_params = {k: self.to_path_value(v)
|
||||
for k, v in iteritems(query_params)}
|
||||
query_params = self.parameters_to_tuples(query_params,
|
||||
collection_formats)
|
||||
|
||||
# post parameters
|
||||
if post_params or files:
|
||||
post_params = self.prepare_post_parameters(post_params, files)
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
post_params = self.parameters_to_tuples(post_params,
|
||||
collection_formats)
|
||||
|
||||
# auth setting
|
||||
self.update_params_for_auth(header_params, query_params, auth_settings)
|
||||
@ -155,20 +161,6 @@ class ApiClient(object):
|
||||
else:
|
||||
return (deserialized_data, response_data.status, response_data.getheaders())
|
||||
|
||||
def to_path_value(self, obj):
|
||||
"""
|
||||
Takes value and turn it into a string suitable for inclusion in
|
||||
the path, by url-encoding.
|
||||
|
||||
:param obj: object or string value.
|
||||
|
||||
:return string: quoted value.
|
||||
"""
|
||||
if type(obj) == list:
|
||||
return ','.join(obj)
|
||||
else:
|
||||
return str(obj)
|
||||
|
||||
def sanitize_for_serialization(self, obj):
|
||||
"""
|
||||
Builds a JSON POST object.
|
||||
@ -281,7 +273,8 @@ class ApiClient(object):
|
||||
def call_api(self, resource_path, method,
|
||||
path_params=None, query_params=None, header_params=None,
|
||||
body=None, post_params=None, files=None,
|
||||
response_type=None, auth_settings=None, callback=None, _return_http_data_only=None):
|
||||
response_type=None, auth_settings=None, callback=None,
|
||||
_return_http_data_only=None, collection_formats=None):
|
||||
"""
|
||||
Makes the HTTP request (synchronous) and return the deserialized data.
|
||||
To make an async request, define a function for callback.
|
||||
@ -303,6 +296,8 @@ class ApiClient(object):
|
||||
If provide this parameter,
|
||||
the request will be called asynchronously.
|
||||
:param _return_http_data_only: response data without head status code and headers
|
||||
:param collection_formats: dict of collection formats for path, query,
|
||||
header, and post parameters.
|
||||
:return:
|
||||
If provide parameter callback,
|
||||
the request will be called asynchronously.
|
||||
@ -314,7 +309,8 @@ class ApiClient(object):
|
||||
return self.__call_api(resource_path, method,
|
||||
path_params, query_params, header_params,
|
||||
body, post_params, files,
|
||||
response_type, auth_settings, callback, _return_http_data_only)
|
||||
response_type, auth_settings, callback,
|
||||
_return_http_data_only, collection_formats)
|
||||
else:
|
||||
thread = threading.Thread(target=self.__call_api,
|
||||
args=(resource_path, method,
|
||||
@ -322,7 +318,8 @@ class ApiClient(object):
|
||||
header_params, body,
|
||||
post_params, files,
|
||||
response_type, auth_settings,
|
||||
callback, _return_http_data_only))
|
||||
callback, _return_http_data_only,
|
||||
collection_formats))
|
||||
thread.start()
|
||||
return thread
|
||||
|
||||
@ -374,30 +371,36 @@ class ApiClient(object):
|
||||
" `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
)
|
||||
|
||||
def parameter_to_tuples(self, collection_format, name, value):
|
||||
def parameters_to_tuples(self, params, collection_formats):
|
||||
"""
|
||||
Get parameter as list of tuples according to collection format.
|
||||
Get parameters as list of tuples, formatting collections.
|
||||
|
||||
:param str collection_format: Collection format
|
||||
:param str name: Parameter name
|
||||
:param value: Parameter value
|
||||
:return: Parameter as list of tuples
|
||||
:param params: Parameters as dict or list of two-tuples
|
||||
:param dict collection_formats: Parameter collection formats
|
||||
:return: Parameters as list of tuples, collections formatted
|
||||
"""
|
||||
if isinstance(value, (list, tuple)):
|
||||
if collection_format == "multi":
|
||||
return [(name, v) for v in value]
|
||||
new_params = []
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in iteritems(params) if isinstance(params, dict) else params:
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == 'multi':
|
||||
new_params.extend((k, value) for value in v)
|
||||
else:
|
||||
if collection_format == 'ssv':
|
||||
delimiter = ' '
|
||||
elif collection_format == 'tsv':
|
||||
delimiter = '\t'
|
||||
elif collection_format == 'pipes':
|
||||
delimiter = '|'
|
||||
else: # csv is the default
|
||||
delimiter = ','
|
||||
new_params.append(
|
||||
(k, delimiter.join(str(value) for value in v)))
|
||||
else:
|
||||
if collection_format == "ssv":
|
||||
delimiter = " "
|
||||
elif collection_format == "tsv":
|
||||
delimiter = "\t"
|
||||
elif collection_format == "pipes":
|
||||
delimiter = "|"
|
||||
else: # csv is the default
|
||||
delimiter = ","
|
||||
return [(name, delimiter.join(value))]
|
||||
else:
|
||||
return [(name, value)]
|
||||
new_params.append((k, v))
|
||||
return new_params
|
||||
|
||||
def prepare_post_parameters(self, post_params=None, files=None):
|
||||
"""
|
||||
@ -466,7 +469,7 @@ class ApiClient(object):
|
||||
Updates header and query params based on authentication setting.
|
||||
|
||||
:param headers: Header parameters dict to be updated.
|
||||
:param querys: Query parameters dict to be updated.
|
||||
:param querys: Query parameters tuple list to be updated.
|
||||
:param auth_settings: Authentication setting identifiers list.
|
||||
"""
|
||||
config = Configuration()
|
||||
@ -482,7 +485,7 @@ class ApiClient(object):
|
||||
elif auth_setting['in'] == 'header':
|
||||
headers[auth_setting['key']] = auth_setting['value']
|
||||
elif auth_setting['in'] == 'query':
|
||||
querys[auth_setting['key']] = auth_setting['value']
|
||||
querys.append((auth_setting['key'], auth_setting['value']))
|
||||
else:
|
||||
raise ValueError(
|
||||
'Authentication token must be in `query` or `header`'
|
||||
|
@ -95,7 +95,8 @@ class ApiClient(object):
|
||||
def __call_api(self, resource_path, method,
|
||||
path_params=None, query_params=None, header_params=None,
|
||||
body=None, post_params=None, files=None,
|
||||
response_type=None, auth_settings=None, callback=None, _return_http_data_only=None):
|
||||
response_type=None, auth_settings=None, callback=None,
|
||||
_return_http_data_only=None, collection_formats=None):
|
||||
|
||||
# header parameters
|
||||
header_params = header_params or {}
|
||||
@ -104,25 +105,30 @@ class ApiClient(object):
|
||||
header_params['Cookie'] = self.cookie
|
||||
if header_params:
|
||||
header_params = self.sanitize_for_serialization(header_params)
|
||||
header_params = dict(self.parameters_to_tuples(header_params,
|
||||
collection_formats))
|
||||
|
||||
# path parameters
|
||||
if path_params:
|
||||
path_params = self.sanitize_for_serialization(path_params)
|
||||
for k, v in iteritems(path_params):
|
||||
replacement = quote(str(self.to_path_value(v)))
|
||||
resource_path = resource_path.\
|
||||
replace('{' + k + '}', replacement)
|
||||
path_params = self.parameters_to_tuples(path_params,
|
||||
collection_formats)
|
||||
for k, v in path_params:
|
||||
resource_path = resource_path.replace(
|
||||
'{%s}' % k, quote(str(v)))
|
||||
|
||||
# query parameters
|
||||
if query_params:
|
||||
query_params = self.sanitize_for_serialization(query_params)
|
||||
query_params = {k: self.to_path_value(v)
|
||||
for k, v in iteritems(query_params)}
|
||||
query_params = self.parameters_to_tuples(query_params,
|
||||
collection_formats)
|
||||
|
||||
# post parameters
|
||||
if post_params or files:
|
||||
post_params = self.prepare_post_parameters(post_params, files)
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
post_params = self.parameters_to_tuples(post_params,
|
||||
collection_formats)
|
||||
|
||||
# auth setting
|
||||
self.update_params_for_auth(header_params, query_params, auth_settings)
|
||||
@ -155,20 +161,6 @@ class ApiClient(object):
|
||||
else:
|
||||
return (deserialized_data, response_data.status, response_data.getheaders())
|
||||
|
||||
def to_path_value(self, obj):
|
||||
"""
|
||||
Takes value and turn it into a string suitable for inclusion in
|
||||
the path, by url-encoding.
|
||||
|
||||
:param obj: object or string value.
|
||||
|
||||
:return string: quoted value.
|
||||
"""
|
||||
if type(obj) == list:
|
||||
return ','.join(obj)
|
||||
else:
|
||||
return str(obj)
|
||||
|
||||
def sanitize_for_serialization(self, obj):
|
||||
"""
|
||||
Builds a JSON POST object.
|
||||
@ -281,7 +273,8 @@ class ApiClient(object):
|
||||
def call_api(self, resource_path, method,
|
||||
path_params=None, query_params=None, header_params=None,
|
||||
body=None, post_params=None, files=None,
|
||||
response_type=None, auth_settings=None, callback=None, _return_http_data_only=None):
|
||||
response_type=None, auth_settings=None, callback=None,
|
||||
_return_http_data_only=None, collection_formats=None):
|
||||
"""
|
||||
Makes the HTTP request (synchronous) and return the deserialized data.
|
||||
To make an async request, define a function for callback.
|
||||
@ -303,6 +296,8 @@ class ApiClient(object):
|
||||
If provide this parameter,
|
||||
the request will be called asynchronously.
|
||||
:param _return_http_data_only: response data without head status code and headers
|
||||
:param collection_formats: dict of collection formats for path, query,
|
||||
header, and post parameters.
|
||||
:return:
|
||||
If provide parameter callback,
|
||||
the request will be called asynchronously.
|
||||
@ -314,7 +309,8 @@ class ApiClient(object):
|
||||
return self.__call_api(resource_path, method,
|
||||
path_params, query_params, header_params,
|
||||
body, post_params, files,
|
||||
response_type, auth_settings, callback, _return_http_data_only)
|
||||
response_type, auth_settings, callback,
|
||||
_return_http_data_only, collection_formats)
|
||||
else:
|
||||
thread = threading.Thread(target=self.__call_api,
|
||||
args=(resource_path, method,
|
||||
@ -322,7 +318,8 @@ class ApiClient(object):
|
||||
header_params, body,
|
||||
post_params, files,
|
||||
response_type, auth_settings,
|
||||
callback, _return_http_data_only))
|
||||
callback, _return_http_data_only,
|
||||
collection_formats))
|
||||
thread.start()
|
||||
return thread
|
||||
|
||||
@ -374,30 +371,36 @@ class ApiClient(object):
|
||||
" `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
)
|
||||
|
||||
def parameter_to_tuples(self, collection_format, name, value):
|
||||
def parameters_to_tuples(self, params, collection_formats):
|
||||
"""
|
||||
Get parameter as list of tuples according to collection format.
|
||||
Get parameters as list of tuples, formatting collections.
|
||||
|
||||
:param str collection_format: Collection format
|
||||
:param str name: Parameter name
|
||||
:param value: Parameter value
|
||||
:return: Parameter as list of tuples
|
||||
:param params: Parameters as dict or list of two-tuples
|
||||
:param dict collection_formats: Parameter collection formats
|
||||
:return: Parameters as list of tuples, collections formatted
|
||||
"""
|
||||
if isinstance(value, (list, tuple)):
|
||||
if collection_format == "multi":
|
||||
return [(name, v) for v in value]
|
||||
new_params = []
|
||||
if collection_formats is None:
|
||||
collection_formats = {}
|
||||
for k, v in iteritems(params) if isinstance(params, dict) else params:
|
||||
if k in collection_formats:
|
||||
collection_format = collection_formats[k]
|
||||
if collection_format == 'multi':
|
||||
new_params.extend((k, value) for value in v)
|
||||
else:
|
||||
if collection_format == 'ssv':
|
||||
delimiter = ' '
|
||||
elif collection_format == 'tsv':
|
||||
delimiter = '\t'
|
||||
elif collection_format == 'pipes':
|
||||
delimiter = '|'
|
||||
else: # csv is the default
|
||||
delimiter = ','
|
||||
new_params.append(
|
||||
(k, delimiter.join(str(value) for value in v)))
|
||||
else:
|
||||
if collection_format == "ssv":
|
||||
delimiter = " "
|
||||
elif collection_format == "tsv":
|
||||
delimiter = "\t"
|
||||
elif collection_format == "pipes":
|
||||
delimiter = "|"
|
||||
else: # csv is the default
|
||||
delimiter = ","
|
||||
return [(name, delimiter.join(value))]
|
||||
else:
|
||||
return [(name, value)]
|
||||
new_params.append((k, v))
|
||||
return new_params
|
||||
|
||||
def prepare_post_parameters(self, post_params=None, files=None):
|
||||
"""
|
||||
@ -466,7 +469,7 @@ class ApiClient(object):
|
||||
Updates header and query params based on authentication setting.
|
||||
|
||||
:param headers: Header parameters dict to be updated.
|
||||
:param querys: Query parameters dict to be updated.
|
||||
:param querys: Query parameters tuple list to be updated.
|
||||
:param auth_settings: Authentication setting identifiers list.
|
||||
"""
|
||||
config = Configuration()
|
||||
@ -482,7 +485,7 @@ class ApiClient(object):
|
||||
elif auth_setting['in'] == 'header':
|
||||
headers[auth_setting['key']] = auth_setting['value']
|
||||
elif auth_setting['in'] == 'query':
|
||||
querys[auth_setting['key']] = auth_setting['value']
|
||||
querys.append((auth_setting['key'], auth_setting['value']))
|
||||
else:
|
||||
raise ValueError(
|
||||
'Authentication token must be in `query` or `header`'
|
||||
|
@ -116,6 +116,9 @@ class FakeApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `test_client_model`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/fake'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -153,7 +156,8 @@ class FakeApi(object):
|
||||
response_type='Client',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def test_endpoint_parameters(self, number, double, pattern_without_delimiter, byte, **kwargs):
|
||||
"""
|
||||
@ -279,6 +283,9 @@ class FakeApi(object):
|
||||
raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be less than or equal to `64`")
|
||||
if 'password' in params and len(params['password']) < 10:
|
||||
raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be greater than or equal to `10`")
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/fake'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -289,31 +296,31 @@ class FakeApi(object):
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
if 'integer' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'integer', params['integer']))
|
||||
form_params.append(('integer', params['integer']))
|
||||
if 'int32' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'int32', params['int32']))
|
||||
form_params.append(('int32', params['int32']))
|
||||
if 'int64' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'int64', params['int64']))
|
||||
form_params.append(('int64', params['int64']))
|
||||
if 'number' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'number', params['number']))
|
||||
form_params.append(('number', params['number']))
|
||||
if 'float' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'float', params['float']))
|
||||
form_params.append(('float', params['float']))
|
||||
if 'double' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'double', params['double']))
|
||||
form_params.append(('double', params['double']))
|
||||
if 'string' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'string', params['string']))
|
||||
form_params.append(('string', params['string']))
|
||||
if 'pattern_without_delimiter' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'pattern_without_delimiter', params['pattern_without_delimiter']))
|
||||
form_params.append(('pattern_without_delimiter', params['pattern_without_delimiter']))
|
||||
if 'byte' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'byte', params['byte']))
|
||||
form_params.append(('byte', params['byte']))
|
||||
if 'binary' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'binary', params['binary']))
|
||||
form_params.append(('binary', params['binary']))
|
||||
if 'date' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'date', params['date']))
|
||||
form_params.append(('date', params['date']))
|
||||
if 'date_time' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'dateTime', params['date_time']))
|
||||
form_params.append(('dateTime', params['date_time']))
|
||||
if 'password' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'password', params['password']))
|
||||
form_params.append(('password', params['password']))
|
||||
|
||||
body_params = None
|
||||
|
||||
@ -340,7 +347,8 @@ class FakeApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def test_enum_parameters(self, **kwargs):
|
||||
"""
|
||||
@ -418,12 +426,16 @@ class FakeApi(object):
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/fake'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
query_params = {}
|
||||
if 'enum_query_string_array' in params:
|
||||
query_params['enum_query_string_array'] = params['enum_query_string_array']
|
||||
collection_formats['enum_query_string_array'] = 'csv'
|
||||
if 'enum_query_string' in params:
|
||||
query_params['enum_query_string'] = params['enum_query_string']
|
||||
if 'enum_query_integer' in params:
|
||||
@ -432,17 +444,19 @@ class FakeApi(object):
|
||||
header_params = {}
|
||||
if 'enum_header_string_array' in params:
|
||||
header_params['enum_header_string_array'] = params['enum_header_string_array']
|
||||
collection_formats['enum_header_string_array'] = 'csv'
|
||||
if 'enum_header_string' in params:
|
||||
header_params['enum_header_string'] = params['enum_header_string']
|
||||
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
if 'enum_form_string_array' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('csv', 'enum_form_string_array', params['enum_form_string_array']))
|
||||
form_params.append(('enum_form_string_array', params['enum_form_string_array']))
|
||||
collection_formats['enum_form_string_array'] = 'csv'
|
||||
if 'enum_form_string' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'enum_form_string', params['enum_form_string']))
|
||||
form_params.append(('enum_form_string', params['enum_form_string']))
|
||||
if 'enum_query_double' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'enum_query_double', params['enum_query_double']))
|
||||
form_params.append(('enum_query_double', params['enum_query_double']))
|
||||
|
||||
body_params = None
|
||||
|
||||
@ -469,4 +483,5 @@ class FakeApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
@ -116,6 +116,9 @@ class PetApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `add_pet`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -153,7 +156,8 @@ class PetApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def delete_pet(self, pet_id, **kwargs):
|
||||
"""
|
||||
@ -222,6 +226,9 @@ class PetApi(object):
|
||||
if ('pet_id' not in params) or (params['pet_id'] is None):
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet/{petId}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'pet_id' in params:
|
||||
@ -261,7 +268,8 @@ class PetApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def find_pets_by_status(self, status, **kwargs):
|
||||
"""
|
||||
@ -328,12 +336,16 @@ class PetApi(object):
|
||||
if ('status' not in params) or (params['status'] is None):
|
||||
raise ValueError("Missing the required parameter `status` when calling `find_pets_by_status`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet/findByStatus'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
query_params = {}
|
||||
if 'status' in params:
|
||||
query_params['status'] = params['status']
|
||||
collection_formats['status'] = 'csv'
|
||||
|
||||
header_params = {}
|
||||
|
||||
@ -365,7 +377,8 @@ class PetApi(object):
|
||||
response_type='list[Pet]',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def find_pets_by_tags(self, tags, **kwargs):
|
||||
"""
|
||||
@ -432,12 +445,16 @@ class PetApi(object):
|
||||
if ('tags' not in params) or (params['tags'] is None):
|
||||
raise ValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet/findByTags'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
query_params = {}
|
||||
if 'tags' in params:
|
||||
query_params['tags'] = params['tags']
|
||||
collection_formats['tags'] = 'csv'
|
||||
|
||||
header_params = {}
|
||||
|
||||
@ -469,7 +486,8 @@ class PetApi(object):
|
||||
response_type='list[Pet]',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def get_pet_by_id(self, pet_id, **kwargs):
|
||||
"""
|
||||
@ -536,6 +554,9 @@ class PetApi(object):
|
||||
if ('pet_id' not in params) or (params['pet_id'] is None):
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet/{petId}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'pet_id' in params:
|
||||
@ -573,7 +594,8 @@ class PetApi(object):
|
||||
response_type='Pet',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def update_pet(self, body, **kwargs):
|
||||
"""
|
||||
@ -640,6 +662,9 @@ class PetApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `update_pet`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -677,7 +702,8 @@ class PetApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def update_pet_with_form(self, pet_id, **kwargs):
|
||||
"""
|
||||
@ -748,6 +774,9 @@ class PetApi(object):
|
||||
if ('pet_id' not in params) or (params['pet_id'] is None):
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet/{petId}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'pet_id' in params:
|
||||
@ -760,9 +789,9 @@ class PetApi(object):
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
if 'name' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'name', params['name']))
|
||||
form_params.append(('name', params['name']))
|
||||
if 'status' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'status', params['status']))
|
||||
form_params.append(('status', params['status']))
|
||||
|
||||
body_params = None
|
||||
|
||||
@ -789,7 +818,8 @@ class PetApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def upload_file(self, pet_id, **kwargs):
|
||||
"""
|
||||
@ -860,6 +890,9 @@ class PetApi(object):
|
||||
if ('pet_id' not in params) or (params['pet_id'] is None):
|
||||
raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'pet_id' in params:
|
||||
@ -872,7 +905,7 @@ class PetApi(object):
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
if 'additional_metadata' in params:
|
||||
form_params.extend(self.api_client.parameter_to_tuples('', 'additionalMetadata', params['additional_metadata']))
|
||||
form_params.append(('additionalMetadata', params['additional_metadata']))
|
||||
if 'file' in params:
|
||||
local_var_files['file'] = params['file']
|
||||
|
||||
@ -901,4 +934,5 @@ class PetApi(object):
|
||||
response_type='ApiResponse',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
@ -118,6 +118,9 @@ class StoreApi(object):
|
||||
|
||||
if 'order_id' in params and params['order_id'] < 1.0:
|
||||
raise ValueError("Invalid value for parameter `order_id` when calling `delete_order`, must be a value greater than or equal to `1.0`")
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'order_id' in params:
|
||||
@ -155,7 +158,8 @@ class StoreApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def get_inventory(self, **kwargs):
|
||||
"""
|
||||
@ -217,6 +221,9 @@ class StoreApi(object):
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/store/inventory'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -252,7 +259,8 @@ class StoreApi(object):
|
||||
response_type='dict(str, int)',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def get_order_by_id(self, order_id, **kwargs):
|
||||
"""
|
||||
@ -323,6 +331,9 @@ class StoreApi(object):
|
||||
raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to `5.0`")
|
||||
if 'order_id' in params and params['order_id'] < 1.0:
|
||||
raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1.0`")
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'order_id' in params:
|
||||
@ -360,7 +371,8 @@ class StoreApi(object):
|
||||
response_type='Order',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def place_order(self, body, **kwargs):
|
||||
"""
|
||||
@ -427,6 +439,9 @@ class StoreApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `place_order`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/store/order'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -464,4 +479,5 @@ class StoreApi(object):
|
||||
response_type='Order',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
@ -116,6 +116,9 @@ class UserApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `create_user`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -153,7 +156,8 @@ class UserApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def create_users_with_array_input(self, body, **kwargs):
|
||||
"""
|
||||
@ -220,6 +224,9 @@ class UserApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `create_users_with_array_input`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user/createWithArray'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -257,7 +264,8 @@ class UserApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def create_users_with_list_input(self, body, **kwargs):
|
||||
"""
|
||||
@ -324,6 +332,9 @@ class UserApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `create_users_with_list_input`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user/createWithList'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -361,7 +372,8 @@ class UserApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def delete_user(self, username, **kwargs):
|
||||
"""
|
||||
@ -428,6 +440,9 @@ class UserApi(object):
|
||||
if ('username' not in params) or (params['username'] is None):
|
||||
raise ValueError("Missing the required parameter `username` when calling `delete_user`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user/{username}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'username' in params:
|
||||
@ -465,7 +480,8 @@ class UserApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def get_user_by_name(self, username, **kwargs):
|
||||
"""
|
||||
@ -532,6 +548,9 @@ class UserApi(object):
|
||||
if ('username' not in params) or (params['username'] is None):
|
||||
raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user/{username}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'username' in params:
|
||||
@ -569,7 +588,8 @@ class UserApi(object):
|
||||
response_type='User',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def login_user(self, username, password, **kwargs):
|
||||
"""
|
||||
@ -641,6 +661,9 @@ class UserApi(object):
|
||||
if ('password' not in params) or (params['password'] is None):
|
||||
raise ValueError("Missing the required parameter `password` when calling `login_user`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user/login'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -680,7 +703,8 @@ class UserApi(object):
|
||||
response_type='str',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def logout_user(self, **kwargs):
|
||||
"""
|
||||
@ -742,6 +766,9 @@ class UserApi(object):
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user/logout'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
@ -777,7 +804,8 @@ class UserApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
||||
def update_user(self, username, body, **kwargs):
|
||||
"""
|
||||
@ -849,6 +877,9 @@ class UserApi(object):
|
||||
if ('body' not in params) or (params['body'] is None):
|
||||
raise ValueError("Missing the required parameter `body` when calling `update_user`")
|
||||
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
resource_path = '/user/{username}'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
if 'username' in params:
|
||||
@ -888,4 +919,5 @@ class UserApi(object):
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
_return_http_data_only=params.get('_return_http_data_only'),
|
||||
collection_formats=collection_formats)
|
||||
|
Loading…
x
Reference in New Issue
Block a user