python: api_client: add the multipart files after sanitization (#2122)

* python: api_client: add the multipart files after sanitization

* simplify prepare_post_parameters

* fix case of both post params and files set

* update samples

* update samples
This commit is contained in:
Matthieu Berthomé 2019-05-07 15:27:01 +02:00 committed by William Cheng
parent a4f2e15bb7
commit f0346aeeb2
6 changed files with 16 additions and 30 deletions

1
.gitignore vendored
View File

@ -40,6 +40,7 @@ packages/
/target
/generated-files
nbactions.xml
test-output/
# website
website/build/

View File

@ -142,10 +142,11 @@ class ApiClient(object):
# post parameters
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = post_params if post_params else []
post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
post_params.extend(self.files_parameters(files))
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
@ -449,18 +450,14 @@ class ApiClient(object):
new_params.append((k, v))
return new_params
def prepare_post_parameters(self, post_params=None, files=None):
def files_parameters(self, files=None):
"""Builds form parameters.
:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.
"""
params = []
if post_params:
params = post_params
if files:
for k, v in six.iteritems(files):
if not v:

View File

@ -144,10 +144,11 @@ class ApiClient(object):
# post parameters
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = post_params if post_params else []
post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
post_params.extend(self.files_parameters(files))
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
@ -442,18 +443,14 @@ class ApiClient(object):
new_params.append((k, v))
return new_params
def prepare_post_parameters(self, post_params=None, files=None):
def files_parameters(self, files=None):
"""Builds form parameters.
:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.
"""
params = []
if post_params:
params = post_params
if files:
for k, v in six.iteritems(files):
if not v:

View File

@ -146,10 +146,11 @@ class ApiClient(object):
# post parameters
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = post_params if post_params else []
post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
post_params.extend(self.files_parameters(files))
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
@ -444,18 +445,14 @@ class ApiClient(object):
new_params.append((k, v))
return new_params
def prepare_post_parameters(self, post_params=None, files=None):
def files_parameters(self, files=None):
"""Builds form parameters.
:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.
"""
params = []
if post_params:
params = post_params
if files:
for k, v in six.iteritems(files):
if not v:

View File

@ -144,10 +144,11 @@ class ApiClient(object):
# post parameters
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = post_params if post_params else []
post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
post_params.extend(self.files_parameters(files))
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
@ -442,18 +443,14 @@ class ApiClient(object):
new_params.append((k, v))
return new_params
def prepare_post_parameters(self, post_params=None, files=None):
def files_parameters(self, files=None):
"""Builds form parameters.
:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.
"""
params = []
if post_params:
params = post_params
if files:
for k, v in six.iteritems(files):
if not v:

View File

@ -144,10 +144,11 @@ class ApiClient(object):
# post parameters
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = post_params if post_params else []
post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
post_params.extend(self.files_parameters(files))
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
@ -442,18 +443,14 @@ class ApiClient(object):
new_params.append((k, v))
return new_params
def prepare_post_parameters(self, post_params=None, files=None):
def files_parameters(self, files=None):
"""Builds form parameters.
:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.
"""
params = []
if post_params:
params = post_params
if files:
for k, v in six.iteritems(files):
if not v: