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:
Ville Skyttä 2016-09-02 11:17:46 +03:00 committed by wing328
parent b909252bb8
commit c43286c569
7 changed files with 250 additions and 139 deletions

View File

@ -140,30 +140,37 @@ class {{classname}}(object):
{{/pattern}} {{/pattern}}
{{/hasValidation}} {{/hasValidation}}
{{/allParams}} {{/allParams}}
collection_formats = {}
resource_path = '{{path}}'.replace('{format}', 'json') resource_path = '{{path}}'.replace('{format}', 'json')
path_params = {} path_params = {}
{{#pathParams}} {{#pathParams}}
if '{{paramName}}' in params: if '{{paramName}}' in params:
path_params['{{baseName}}'] = params['{{paramName}}'] path_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}}
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}}
{{/pathParams}} {{/pathParams}}
query_params = {} query_params = {}
{{#queryParams}} {{#queryParams}}
if '{{paramName}}' in params: if '{{paramName}}' in params:
query_params['{{baseName}}'] = params['{{paramName}}'] query_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}}
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}}
{{/queryParams}} {{/queryParams}}
header_params = {} header_params = {}
{{#headerParams}} {{#headerParams}}
if '{{paramName}}' in params: if '{{paramName}}' in params:
header_params['{{baseName}}'] = params['{{paramName}}'] header_params['{{baseName}}'] = params['{{paramName}}']{{#isListContainer}}
collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}}
{{/headerParams}} {{/headerParams}}
form_params = [] form_params = []
local_var_files = {} local_var_files = {}
{{#formParams}} {{#formParams}}
if '{{paramName}}' in params: 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}} {{/formParams}}
body_params = None body_params = None
@ -195,6 +202,7 @@ class {{classname}}(object):
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}},
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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}} {{/operation}}
{{/operations}} {{/operations}}

View File

@ -95,7 +95,8 @@ class ApiClient(object):
def __call_api(self, resource_path, method, def __call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None, path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=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 parameters
header_params = header_params or {} header_params = header_params or {}
@ -104,25 +105,30 @@ class ApiClient(object):
header_params['Cookie'] = self.cookie header_params['Cookie'] = self.cookie
if header_params: if header_params:
header_params = self.sanitize_for_serialization(header_params) header_params = self.sanitize_for_serialization(header_params)
header_params = dict(self.parameters_to_tuples(header_params,
collection_formats))
# path parameters # path parameters
if path_params: if path_params:
path_params = self.sanitize_for_serialization(path_params) path_params = self.sanitize_for_serialization(path_params)
for k, v in iteritems(path_params): path_params = self.parameters_to_tuples(path_params,
replacement = quote(str(self.to_path_value(v))) collection_formats)
resource_path = resource_path.\ for k, v in path_params:
replace('{' + k + '}', replacement) resource_path = resource_path.replace(
'{%s}' % k, quote(str(v)))
# query parameters # query parameters
if query_params: if query_params:
query_params = self.sanitize_for_serialization(query_params) query_params = self.sanitize_for_serialization(query_params)
query_params = {k: self.to_path_value(v) query_params = self.parameters_to_tuples(query_params,
for k, v in iteritems(query_params)} collection_formats)
# post parameters # post parameters
if post_params or files: if post_params or files:
post_params = self.prepare_post_parameters(post_params, files) post_params = self.prepare_post_parameters(post_params, files)
post_params = self.sanitize_for_serialization(post_params) post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
# auth setting # auth setting
self.update_params_for_auth(header_params, query_params, auth_settings) self.update_params_for_auth(header_params, query_params, auth_settings)
@ -155,20 +161,6 @@ class ApiClient(object):
else: else:
return (deserialized_data, response_data.status, response_data.getheaders()) 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): def sanitize_for_serialization(self, obj):
""" """
Builds a JSON POST object. Builds a JSON POST object.
@ -281,7 +273,8 @@ class ApiClient(object):
def call_api(self, resource_path, method, def call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None, path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=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. Makes the HTTP request (synchronous) and return the deserialized data.
To make an async request, define a function for callback. To make an async request, define a function for callback.
@ -303,6 +296,8 @@ class ApiClient(object):
If provide this parameter, If provide this parameter,
the request will be called asynchronously. the request will be called asynchronously.
:param _return_http_data_only: response data without head status code and headers :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: :return:
If provide parameter callback, If provide parameter callback,
the request will be called asynchronously. the request will be called asynchronously.
@ -314,7 +309,8 @@ class ApiClient(object):
return self.__call_api(resource_path, method, return self.__call_api(resource_path, method,
path_params, query_params, header_params, path_params, query_params, header_params,
body, post_params, files, 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: else:
thread = threading.Thread(target=self.__call_api, thread = threading.Thread(target=self.__call_api,
args=(resource_path, method, args=(resource_path, method,
@ -322,7 +318,8 @@ class ApiClient(object):
header_params, body, header_params, body,
post_params, files, post_params, files,
response_type, auth_settings, response_type, auth_settings,
callback, _return_http_data_only)) callback, _return_http_data_only,
collection_formats))
thread.start() thread.start()
return thread return thread
@ -374,30 +371,36 @@ class ApiClient(object):
" `POST`, `PATCH`, `PUT` or `DELETE`." " `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 params: Parameters as dict or list of two-tuples
:param str name: Parameter name :param dict collection_formats: Parameter collection formats
:param value: Parameter value :return: Parameters as list of tuples, collections formatted
:return: Parameter as list of tuples
""" """
if isinstance(value, (list, tuple)): new_params = []
if collection_format == "multi": if collection_formats is None:
return [(name, v) for v in value] 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: else:
if collection_format == "ssv": new_params.append((k, v))
delimiter = " " return new_params
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)]
def prepare_post_parameters(self, post_params=None, files=None): 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. Updates header and query params based on authentication setting.
:param headers: Header parameters dict to be updated. :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. :param auth_settings: Authentication setting identifiers list.
""" """
config = Configuration() config = Configuration()
@ -482,7 +485,7 @@ class ApiClient(object):
elif auth_setting['in'] == 'header': elif auth_setting['in'] == 'header':
headers[auth_setting['key']] = auth_setting['value'] headers[auth_setting['key']] = auth_setting['value']
elif auth_setting['in'] == 'query': elif auth_setting['in'] == 'query':
querys[auth_setting['key']] = auth_setting['value'] querys.append((auth_setting['key'], auth_setting['value']))
else: else:
raise ValueError( raise ValueError(
'Authentication token must be in `query` or `header`' 'Authentication token must be in `query` or `header`'

View File

@ -95,7 +95,8 @@ class ApiClient(object):
def __call_api(self, resource_path, method, def __call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None, path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=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 parameters
header_params = header_params or {} header_params = header_params or {}
@ -104,25 +105,30 @@ class ApiClient(object):
header_params['Cookie'] = self.cookie header_params['Cookie'] = self.cookie
if header_params: if header_params:
header_params = self.sanitize_for_serialization(header_params) header_params = self.sanitize_for_serialization(header_params)
header_params = dict(self.parameters_to_tuples(header_params,
collection_formats))
# path parameters # path parameters
if path_params: if path_params:
path_params = self.sanitize_for_serialization(path_params) path_params = self.sanitize_for_serialization(path_params)
for k, v in iteritems(path_params): path_params = self.parameters_to_tuples(path_params,
replacement = quote(str(self.to_path_value(v))) collection_formats)
resource_path = resource_path.\ for k, v in path_params:
replace('{' + k + '}', replacement) resource_path = resource_path.replace(
'{%s}' % k, quote(str(v)))
# query parameters # query parameters
if query_params: if query_params:
query_params = self.sanitize_for_serialization(query_params) query_params = self.sanitize_for_serialization(query_params)
query_params = {k: self.to_path_value(v) query_params = self.parameters_to_tuples(query_params,
for k, v in iteritems(query_params)} collection_formats)
# post parameters # post parameters
if post_params or files: if post_params or files:
post_params = self.prepare_post_parameters(post_params, files) post_params = self.prepare_post_parameters(post_params, files)
post_params = self.sanitize_for_serialization(post_params) post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
# auth setting # auth setting
self.update_params_for_auth(header_params, query_params, auth_settings) self.update_params_for_auth(header_params, query_params, auth_settings)
@ -155,20 +161,6 @@ class ApiClient(object):
else: else:
return (deserialized_data, response_data.status, response_data.getheaders()) 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): def sanitize_for_serialization(self, obj):
""" """
Builds a JSON POST object. Builds a JSON POST object.
@ -281,7 +273,8 @@ class ApiClient(object):
def call_api(self, resource_path, method, def call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None, path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=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. Makes the HTTP request (synchronous) and return the deserialized data.
To make an async request, define a function for callback. To make an async request, define a function for callback.
@ -303,6 +296,8 @@ class ApiClient(object):
If provide this parameter, If provide this parameter,
the request will be called asynchronously. the request will be called asynchronously.
:param _return_http_data_only: response data without head status code and headers :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: :return:
If provide parameter callback, If provide parameter callback,
the request will be called asynchronously. the request will be called asynchronously.
@ -314,7 +309,8 @@ class ApiClient(object):
return self.__call_api(resource_path, method, return self.__call_api(resource_path, method,
path_params, query_params, header_params, path_params, query_params, header_params,
body, post_params, files, 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: else:
thread = threading.Thread(target=self.__call_api, thread = threading.Thread(target=self.__call_api,
args=(resource_path, method, args=(resource_path, method,
@ -322,7 +318,8 @@ class ApiClient(object):
header_params, body, header_params, body,
post_params, files, post_params, files,
response_type, auth_settings, response_type, auth_settings,
callback, _return_http_data_only)) callback, _return_http_data_only,
collection_formats))
thread.start() thread.start()
return thread return thread
@ -374,30 +371,36 @@ class ApiClient(object):
" `POST`, `PATCH`, `PUT` or `DELETE`." " `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 params: Parameters as dict or list of two-tuples
:param str name: Parameter name :param dict collection_formats: Parameter collection formats
:param value: Parameter value :return: Parameters as list of tuples, collections formatted
:return: Parameter as list of tuples
""" """
if isinstance(value, (list, tuple)): new_params = []
if collection_format == "multi": if collection_formats is None:
return [(name, v) for v in value] 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: else:
if collection_format == "ssv": new_params.append((k, v))
delimiter = " " return new_params
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)]
def prepare_post_parameters(self, post_params=None, files=None): 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. Updates header and query params based on authentication setting.
:param headers: Header parameters dict to be updated. :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. :param auth_settings: Authentication setting identifiers list.
""" """
config = Configuration() config = Configuration()
@ -482,7 +485,7 @@ class ApiClient(object):
elif auth_setting['in'] == 'header': elif auth_setting['in'] == 'header':
headers[auth_setting['key']] = auth_setting['value'] headers[auth_setting['key']] = auth_setting['value']
elif auth_setting['in'] == 'query': elif auth_setting['in'] == 'query':
querys[auth_setting['key']] = auth_setting['value'] querys.append((auth_setting['key'], auth_setting['value']))
else: else:
raise ValueError( raise ValueError(
'Authentication token must be in `query` or `header`' 'Authentication token must be in `query` or `header`'

View File

@ -116,6 +116,9 @@ class FakeApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `test_client_model`") raise ValueError("Missing the required parameter `body` when calling `test_client_model`")
collection_formats = {}
resource_path = '/fake'.replace('{format}', 'json') resource_path = '/fake'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -153,7 +156,8 @@ class FakeApi(object):
response_type='Client', response_type='Client',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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`") 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: 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`") 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') resource_path = '/fake'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -289,31 +296,31 @@ class FakeApi(object):
form_params = [] form_params = []
local_var_files = {} local_var_files = {}
if 'integer' in params: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 body_params = None
@ -340,7 +347,8 @@ class FakeApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def test_enum_parameters(self, **kwargs):
""" """
@ -418,12 +426,16 @@ class FakeApi(object):
params[key] = val params[key] = val
del params['kwargs'] del params['kwargs']
collection_formats = {}
resource_path = '/fake'.replace('{format}', 'json') resource_path = '/fake'.replace('{format}', 'json')
path_params = {} path_params = {}
query_params = {} query_params = {}
if 'enum_query_string_array' in params: if 'enum_query_string_array' in params:
query_params['enum_query_string_array'] = params['enum_query_string_array'] query_params['enum_query_string_array'] = params['enum_query_string_array']
collection_formats['enum_query_string_array'] = 'csv'
if 'enum_query_string' in params: if 'enum_query_string' in params:
query_params['enum_query_string'] = params['enum_query_string'] query_params['enum_query_string'] = params['enum_query_string']
if 'enum_query_integer' in params: if 'enum_query_integer' in params:
@ -432,17 +444,19 @@ class FakeApi(object):
header_params = {} header_params = {}
if 'enum_header_string_array' in params: if 'enum_header_string_array' in params:
header_params['enum_header_string_array'] = params['enum_header_string_array'] header_params['enum_header_string_array'] = params['enum_header_string_array']
collection_formats['enum_header_string_array'] = 'csv'
if 'enum_header_string' in params: if 'enum_header_string' in params:
header_params['enum_header_string'] = params['enum_header_string'] header_params['enum_header_string'] = params['enum_header_string']
form_params = [] form_params = []
local_var_files = {} local_var_files = {}
if 'enum_form_string_array' in params: 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: 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: 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 body_params = None
@ -469,4 +483,5 @@ class FakeApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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)

View File

@ -116,6 +116,9 @@ class PetApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `add_pet`") raise ValueError("Missing the required parameter `body` when calling `add_pet`")
collection_formats = {}
resource_path = '/pet'.replace('{format}', 'json') resource_path = '/pet'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -153,7 +156,8 @@ class PetApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): if ('pet_id' not in params) or (params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`")
collection_formats = {}
resource_path = '/pet/{petId}'.replace('{format}', 'json') resource_path = '/pet/{petId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:
@ -261,7 +268,8 @@ class PetApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): if ('status' not in params) or (params['status'] is None):
raise ValueError("Missing the required parameter `status` when calling `find_pets_by_status`") raise ValueError("Missing the required parameter `status` when calling `find_pets_by_status`")
collection_formats = {}
resource_path = '/pet/findByStatus'.replace('{format}', 'json') resource_path = '/pet/findByStatus'.replace('{format}', 'json')
path_params = {} path_params = {}
query_params = {} query_params = {}
if 'status' in params: if 'status' in params:
query_params['status'] = params['status'] query_params['status'] = params['status']
collection_formats['status'] = 'csv'
header_params = {} header_params = {}
@ -365,7 +377,8 @@ class PetApi(object):
response_type='list[Pet]', response_type='list[Pet]',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): if ('tags' not in params) or (params['tags'] is None):
raise ValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`") raise ValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`")
collection_formats = {}
resource_path = '/pet/findByTags'.replace('{format}', 'json') resource_path = '/pet/findByTags'.replace('{format}', 'json')
path_params = {} path_params = {}
query_params = {} query_params = {}
if 'tags' in params: if 'tags' in params:
query_params['tags'] = params['tags'] query_params['tags'] = params['tags']
collection_formats['tags'] = 'csv'
header_params = {} header_params = {}
@ -469,7 +486,8 @@ class PetApi(object):
response_type='list[Pet]', response_type='list[Pet]',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): 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`") raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`")
collection_formats = {}
resource_path = '/pet/{petId}'.replace('{format}', 'json') resource_path = '/pet/{petId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:
@ -573,7 +594,8 @@ class PetApi(object):
response_type='Pet', response_type='Pet',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def update_pet(self, body, **kwargs):
""" """
@ -640,6 +662,9 @@ class PetApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `update_pet`") raise ValueError("Missing the required parameter `body` when calling `update_pet`")
collection_formats = {}
resource_path = '/pet'.replace('{format}', 'json') resource_path = '/pet'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -677,7 +702,8 @@ class PetApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): 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`") raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`")
collection_formats = {}
resource_path = '/pet/{petId}'.replace('{format}', 'json') resource_path = '/pet/{petId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:
@ -760,9 +789,9 @@ class PetApi(object):
form_params = [] form_params = []
local_var_files = {} local_var_files = {}
if 'name' in params: 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: 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 body_params = None
@ -789,7 +818,8 @@ class PetApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): if ('pet_id' not in params) or (params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`")
collection_formats = {}
resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json') resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:
@ -872,7 +905,7 @@ class PetApi(object):
form_params = [] form_params = []
local_var_files = {} local_var_files = {}
if 'additional_metadata' in params: 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: if 'file' in params:
local_var_files['file'] = params['file'] local_var_files['file'] = params['file']
@ -901,4 +934,5 @@ class PetApi(object):
response_type='ApiResponse', response_type='ApiResponse',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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)

View File

@ -118,6 +118,9 @@ class StoreApi(object):
if 'order_id' in params and params['order_id'] < 1.0: 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`") 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') resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'order_id' in params: if 'order_id' in params:
@ -155,7 +158,8 @@ class StoreApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def get_inventory(self, **kwargs):
""" """
@ -217,6 +221,9 @@ class StoreApi(object):
params[key] = val params[key] = val
del params['kwargs'] del params['kwargs']
collection_formats = {}
resource_path = '/store/inventory'.replace('{format}', 'json') resource_path = '/store/inventory'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -252,7 +259,8 @@ class StoreApi(object):
response_type='dict(str, int)', response_type='dict(str, int)',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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`") 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: 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`") 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') resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'order_id' in params: if 'order_id' in params:
@ -360,7 +371,8 @@ class StoreApi(object):
response_type='Order', response_type='Order',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def place_order(self, body, **kwargs):
""" """
@ -427,6 +439,9 @@ class StoreApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `place_order`") raise ValueError("Missing the required parameter `body` when calling `place_order`")
collection_formats = {}
resource_path = '/store/order'.replace('{format}', 'json') resource_path = '/store/order'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -464,4 +479,5 @@ class StoreApi(object):
response_type='Order', response_type='Order',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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)

View File

@ -116,6 +116,9 @@ class UserApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_user`") raise ValueError("Missing the required parameter `body` when calling `create_user`")
collection_formats = {}
resource_path = '/user'.replace('{format}', 'json') resource_path = '/user'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -153,7 +156,8 @@ class UserApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_users_with_array_input`") raise ValueError("Missing the required parameter `body` when calling `create_users_with_array_input`")
collection_formats = {}
resource_path = '/user/createWithArray'.replace('{format}', 'json') resource_path = '/user/createWithArray'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -257,7 +264,8 @@ class UserApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_users_with_list_input`") raise ValueError("Missing the required parameter `body` when calling `create_users_with_list_input`")
collection_formats = {}
resource_path = '/user/createWithList'.replace('{format}', 'json') resource_path = '/user/createWithList'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -361,7 +372,8 @@ class UserApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def delete_user(self, username, **kwargs):
""" """
@ -428,6 +440,9 @@ class UserApi(object):
if ('username' not in params) or (params['username'] is None): if ('username' not in params) or (params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `delete_user`") raise ValueError("Missing the required parameter `username` when calling `delete_user`")
collection_formats = {}
resource_path = '/user/{username}'.replace('{format}', 'json') resource_path = '/user/{username}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'username' in params: if 'username' in params:
@ -465,7 +480,8 @@ class UserApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): 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): if ('username' not in params) or (params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`")
collection_formats = {}
resource_path = '/user/{username}'.replace('{format}', 'json') resource_path = '/user/{username}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'username' in params: if 'username' in params:
@ -569,7 +588,8 @@ class UserApi(object):
response_type='User', response_type='User',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def login_user(self, username, password, **kwargs):
""" """
@ -641,6 +661,9 @@ class UserApi(object):
if ('password' not in params) or (params['password'] is None): if ('password' not in params) or (params['password'] is None):
raise ValueError("Missing the required parameter `password` when calling `login_user`") raise ValueError("Missing the required parameter `password` when calling `login_user`")
collection_formats = {}
resource_path = '/user/login'.replace('{format}', 'json') resource_path = '/user/login'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -680,7 +703,8 @@ class UserApi(object):
response_type='str', response_type='str',
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def logout_user(self, **kwargs):
""" """
@ -742,6 +766,9 @@ class UserApi(object):
params[key] = val params[key] = val
del params['kwargs'] del params['kwargs']
collection_formats = {}
resource_path = '/user/logout'.replace('{format}', 'json') resource_path = '/user/logout'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -777,7 +804,8 @@ class UserApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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): def update_user(self, username, body, **kwargs):
""" """
@ -849,6 +877,9 @@ class UserApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `update_user`") raise ValueError("Missing the required parameter `body` when calling `update_user`")
collection_formats = {}
resource_path = '/user/{username}'.replace('{format}', 'json') resource_path = '/user/{username}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'username' in params: if 'username' in params:
@ -888,4 +919,5 @@ class UserApi(object):
response_type=None, response_type=None,
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback'), 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)