mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
Merge pull request #1295 from geekerzp/python_upload_file
[Python] Fix issue in python client
This commit is contained in:
commit
e301020acc
@ -126,7 +126,7 @@ class ApiClient(object):
|
||||
for k, v in iteritems(query_params)}
|
||||
|
||||
# post parameters
|
||||
if post_params:
|
||||
if post_params or files:
|
||||
post_params = self.prepare_post_parameters(post_params, files)
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
|
||||
|
@ -126,7 +126,7 @@ class ApiClient(object):
|
||||
for k, v in iteritems(query_params)}
|
||||
|
||||
# post parameters
|
||||
if post_params:
|
||||
if post_params or files:
|
||||
post_params = self.prepare_post_parameters(post_params, files)
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
|
||||
|
@ -137,6 +137,7 @@ class PetApiTests(unittest.TestCase):
|
||||
self.assertEqual(status, fetched.status)
|
||||
|
||||
def test_upload_file(self):
|
||||
# upload file with form parameter
|
||||
try:
|
||||
additional_metadata = "special"
|
||||
self.pet_api.upload_file(
|
||||
@ -147,6 +148,12 @@ class PetApiTests(unittest.TestCase):
|
||||
except ApiException as e:
|
||||
self.fail("upload_file() raised {0} unexpectedly".format(type(e)))
|
||||
|
||||
# upload only file
|
||||
try:
|
||||
self.pet_api.upload_file(pet_id=self.pet.id, file=self.foo)
|
||||
except ApiException as e:
|
||||
self.fail("upload_file() raised {0} unexpectedly".format(type(e)))
|
||||
|
||||
def test_delete_pet(self):
|
||||
self.pet_api.add_pet(body=self.pet)
|
||||
self.pet_api.delete_pet(pet_id=self.pet.id, api_key="special-key")
|
||||
@ -159,8 +166,3 @@ class PetApiTests(unittest.TestCase):
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user