forked from loafle/openapi-generator-original
fix(python,asyncio): multipart form data serialization (#19302)
* fix: object serialization for multipart requests
This PR is essentially
<https://github.com/OpenAPITools/openapi-generator/pull/18140> but for
the asyncio client.
* fix: int serialization for multipart requests
urllib3 handles serializing ints in post params (ref 1), while asyncio
explicitly does not (ref 2).
ref 1: <9316764e90/src/urllib3/filepost.py (L75-L76)>
ref 2: <https://github.com/aio-libs/aiohttp/issues/920>
* test: new fake multipart endpoint with files and body
* test: regression test for stringified body params
* fix: mypy tweak
* fix: FILES regeneration
* feat: object, int serialization for multipart reqs
Extends previous commits (and #18140) to cover the python-pydantic-v1
client as well.
* fix: use async with in test
* test: regression test for pydantic-v1-aiohttp
* test: add regression test to pydantic-v1
Also brings the second test in line with the first, patching
`urllib3.PoolManager.urlopen`
This commit is contained in:
@@ -201,6 +201,8 @@ class RESTClientObject:
|
||||
# Content-Type which generated by urllib3 will be
|
||||
# overwritten.
|
||||
del headers['Content-Type']
|
||||
# Ensures that dict objects are serialized
|
||||
post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params]
|
||||
r = self.pool_manager.request(
|
||||
method, url,
|
||||
fields=post_params,
|
||||
|
||||
Reference in New Issue
Block a user