Skip to content

Commit

Permalink
[Python] Fix object serialization for multipart requests (#18140)
Browse files Browse the repository at this point in the history
* Fix multipart object serialization

* Update samples
  • Loading branch information
Poolmann authored Mar 19, 2024
1 parent e58f19c commit b7ea139
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def request(
# 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,
Expand Down
2 changes: 2 additions & 0 deletions samples/client/echo_api/python/openapi_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def request(
# 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,
Expand Down
2 changes: 2 additions & 0 deletions samples/openapi3/client/petstore/python/petstore_api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def request(
# 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,
Expand Down

0 comments on commit b7ea139

Please sign in to comment.