Skip to content

Commit 1064cb6

Browse files
wing328ziodave
andauthored
Allow to pass a str to the Python aiohttp client (#18985)
* see #18972 Add support for `str` * update python samples --------- Co-authored-by: David Riccitelli <[email protected]>
1 parent 4e89436 commit 1064cb6

File tree

2 files changed

+4
-4
lines changed
  • modules/openapi-generator/src/main/resources/python/asyncio
  • samples/openapi3/client/petstore/python-aiohttp/petstore_api

2 files changed

+4
-4
lines changed

modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ class RESTClientObject:
177177
data.add_field(k, v)
178178
args["data"] = data
179179

180-
# Pass a `bytes` parameter directly in the body to support
180+
# Pass a `bytes` or `str` parameter directly in the body to support
181181
# other content types than Json when `body` argument is provided
182182
# in serialized form
183-
elif isinstance(body, bytes):
183+
elif isinstance(body, str) or isinstance(body, bytes):
184184
args["data"] = body
185185
else:
186186
# Cannot generate the request from given parameters

samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ async def request(
187187
data.add_field(k, v)
188188
args["data"] = data
189189

190-
# Pass a `bytes` parameter directly in the body to support
190+
# Pass a `bytes` or `str` parameter directly in the body to support
191191
# other content types than Json when `body` argument is provided
192192
# in serialized form
193-
elif isinstance(body, bytes):
193+
elif isinstance(body, str) or isinstance(body, bytes):
194194
args["data"] = body
195195
else:
196196
# Cannot generate the request from given parameters

0 commit comments

Comments
 (0)