Don't cast list to tuple in python-prior binding (#14014)

* Add test for python-prior type conversion error

In the spirit of test driven development, this test intentionally fails.
A following commit will fix the code to comply with the test.

See: https://github.com/OpenAPITools/openapi-generator/issues/14012

* Don't cast list to tuple in python-prior binding

Tweak the python-prior API bindings, so that they no longer cast lists
to tuples when making a POST request with a multipart/form-data
content-type. This fixes an interaction with
`urllib3.request_encode_body`, whose `fields` parameter expects tuples,
not lists.

cc @spacether

See: https://urllib3.readthedocs.io/en/stable/reference/urllib3.request.html

Fix: https://github.com/OpenAPITools/openapi-generator/issues/14012
This commit is contained in:
Jeremy Audet
2022-11-15 20:40:28 -05:00
committed by GitHub
parent 77226981b6
commit 92ecee8c27
6 changed files with 60 additions and 5 deletions

View File

@@ -286,8 +286,10 @@ class ApiClient(object):
return obj.isoformat()
elif isinstance(obj, ModelSimple):
return cls.sanitize_for_serialization(obj.value)
elif isinstance(obj, (list, tuple)):
elif isinstance(obj, list):
return [cls.sanitize_for_serialization(item) for item in obj]
elif isinstance(obj, tuple):
return tuple(cls.sanitize_for_serialization(item) for item in obj)
if isinstance(obj, dict):
return {key: cls.sanitize_for_serialization(val) for key, val in obj.items()}
raise ApiValueError(