From 1064cb6a68a30930179c2d3d6dc6bf72f67982a8 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 23 Jun 2024 17:19:26 +0800 Subject: [PATCH] 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 --- .../src/main/resources/python/asyncio/rest.mustache | 4 ++-- .../client/petstore/python-aiohttp/petstore_api/rest.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache index 7cf3499fadf..edfcc66727e 100644 --- a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache @@ -177,10 +177,10 @@ class RESTClientObject: data.add_field(k, v) args["data"] = data - # Pass a `bytes` parameter directly in the body to support + # Pass a `bytes` or `str` parameter directly in the body to support # other content types than Json when `body` argument is provided # in serialized form - elif isinstance(body, bytes): + elif isinstance(body, str) or isinstance(body, bytes): args["data"] = body else: # Cannot generate the request from given parameters diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py index 147076895fc..ffdf1f9d400 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py @@ -187,10 +187,10 @@ class RESTClientObject: data.add_field(k, v) args["data"] = data - # Pass a `bytes` parameter directly in the body to support + # Pass a `bytes` or `str` parameter directly in the body to support # other content types than Json when `body` argument is provided # in serialized form - elif isinstance(body, bytes): + elif isinstance(body, str) or isinstance(body, bytes): args["data"] = body else: # Cannot generate the request from given parameters