diff --git a/modules/openapi-generator/src/main/resources/python-nextgen/api_client.mustache b/modules/openapi-generator/src/main/resources/python-nextgen/api_client.mustache index dc548d506a..5c79cf16e7 100644 --- a/modules/openapi-generator/src/main/resources/python-nextgen/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python-nextgen/api_client.mustache @@ -549,6 +549,8 @@ class ApiClient(object): v = str(v) if isinstance(v, bool): v = str(v).lower() + if isinstance(v, dict): + v = json.dumps(v) if k in collection_formats: collection_format = collection_formats[k] diff --git a/samples/client/echo_api/python-nextgen/openapi_client/api_client.py b/samples/client/echo_api/python-nextgen/openapi_client/api_client.py index 321a53d8c5..8ba7f3780d 100644 --- a/samples/client/echo_api/python-nextgen/openapi_client/api_client.py +++ b/samples/client/echo_api/python-nextgen/openapi_client/api_client.py @@ -526,6 +526,8 @@ class ApiClient(object): v = str(v) if isinstance(v, bool): v = str(v).lower() + if isinstance(v, dict): + v = json.dumps(v) if k in collection_formats: collection_format = collection_formats[k] diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/api_client.py index 52577d0c81..6db495c8b0 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/api_client.py @@ -526,6 +526,8 @@ class ApiClient(object): v = str(v) if isinstance(v, bool): v = str(v).lower() + if isinstance(v, dict): + v = json.dumps(v) if k in collection_formats: collection_format = collection_formats[k] diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/api_client.py index a3b04e67d0..55b0b1db8b 100755 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/api_client.py @@ -525,6 +525,8 @@ class ApiClient(object): v = str(v) if isinstance(v, bool): v = str(v).lower() + if isinstance(v, dict): + v = json.dumps(v) if k in collection_formats: collection_format = collection_formats[k] diff --git a/samples/openapi3/client/petstore/python-nextgen/tests/test_api_client.py b/samples/openapi3/client/petstore/python-nextgen/tests/test_api_client.py index 27ef96481a..d4de69555c 100644 --- a/samples/openapi3/client/petstore/python-nextgen/tests/test_api_client.py +++ b/samples/openapi3/client/petstore/python-nextgen/tests/test_api_client.py @@ -212,3 +212,50 @@ class ApiClientTests(unittest.TestCase): self.assertIsNotNone(client._pool) atexit._run_exitfuncs() self.assertIsNone(client._pool) + + def test_parameters_to_url_query(self): + data = 'value={"category": "example", "category2": "example2"}' + dictionary = { + "category": "example", + "category2": "example2" + } + result = self.api_client.parameters_to_url_query([('value', dictionary)], {}) + self.assertEqual(result, data) + + data='value={"number": 1, "string": "str", "bool": true, "dict": {"number": 1, "string": "str", "bool": true}}' + dictionary = { + "number": 1, + "string": "str", + "bool": True, + "dict": { + "number": 1, + "string": "str", + "bool": True + } + } + result = self.api_client.parameters_to_url_query([('value', dictionary)], {}) + self.assertEqual(result, data) + + data='value={"strValues": ["one", "two", "three"], "dictValues": [{"name": "value1", "age": 14}, {"name": "value2", "age": 12}]}' + dictionary = { + "strValues": [ + "one", + "two", + "three" + ], + "dictValues": [ + { + "name": "value1", + "age": 14 + }, + { + "name": "value2", + "age": 12 + }, + ] + } + result = self.api_client.parameters_to_url_query([('value', dictionary)], {}) + self.assertEqual(result, data) + + +