diff --git a/modules/openapi-generator/src/main/resources/python-pydantic-v1/api_client.mustache b/modules/openapi-generator/src/main/resources/python-pydantic-v1/api_client.mustache index fe61bd61a5e..7c7bfcdc7d5 100644 --- a/modules/openapi-generator/src/main/resources/python-pydantic-v1/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python-pydantic-v1/api_client.mustache @@ -577,7 +577,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index 8c9812db7d2..83b21860d55 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -491,7 +491,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py index ce93eaca6de..262f9aecfa7 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py @@ -484,7 +484,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/client/echo_api/python-pydantic-v1/openapi_client/api_client.py b/samples/client/echo_api/python-pydantic-v1/openapi_client/api_client.py index 459e3850849..6383d7e39e7 100644 --- a/samples/client/echo_api/python-pydantic-v1/openapi_client/api_client.py +++ b/samples/client/echo_api/python-pydantic-v1/openapi_client/api_client.py @@ -539,7 +539,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/client/echo_api/python-pydantic-v1/test/test_manual.py b/samples/client/echo_api/python-pydantic-v1/test/test_manual.py index fedf4cfad6b..202cf2dd196 100644 --- a/samples/client/echo_api/python-pydantic-v1/test/test_manual.py +++ b/samples/client/echo_api/python-pydantic-v1/test/test_manual.py @@ -149,6 +149,12 @@ class TestManual(unittest.TestCase): client = openapi_client.ApiClient() params = client.parameters_to_url_query([("boolean", True),], {}) self.assertEqual(params, "boolean=true") + + def test_parameters_to_url_query_list_value(self): + client = openapi_client.ApiClient() + params = client.parameters_to_url_query(params=[('list', [1, 2, 3])], collection_formats={'list': 'multi'}) + self.assertEqual(params, "list=1&list=2&list=3") + def echoServerResponseParaserTest(self): s = """POST /echo/body/Pet/response_string HTTP/1.1 diff --git a/samples/client/echo_api/python/openapi_client/api_client.py b/samples/client/echo_api/python/openapi_client/api_client.py index ce93eaca6de..262f9aecfa7 100644 --- a/samples/client/echo_api/python/openapi_client/api_client.py +++ b/samples/client/echo_api/python/openapi_client/api_client.py @@ -484,7 +484,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/client/echo_api/python/tests/test_manual.py b/samples/client/echo_api/python/tests/test_manual.py index 17e0e101405..525c0875854 100644 --- a/samples/client/echo_api/python/tests/test_manual.py +++ b/samples/client/echo_api/python/tests/test_manual.py @@ -224,7 +224,12 @@ class TestManual(unittest.TestCase): client = openapi_client.ApiClient() params = client.parameters_to_url_query([("boolean", True),], {}) self.assertEqual(params, "boolean=true") - + + def test_parameters_to_url_query_list_value(self): + client = openapi_client.ApiClient() + params = client.parameters_to_url_query(params=[('list', [1, 2, 3])], collection_formats={'list': 'multi'}) + self.assertEqual(params, "list=1&list=2&list=3") + def echoServerResponseParaserTest(self): s = """POST /echo/body/Pet/response_string HTTP/1.1 Host: localhost:3000 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py index 5e403f5a51a..fdb8c16ab6b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py @@ -486,7 +486,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api_client.py index dbef903bdd6..9fefc1b1ae0 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api_client.py @@ -509,7 +509,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api_client.py index 2a74a7d7004..1b4f238f9dd 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api_client.py @@ -538,7 +538,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_client.py b/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_client.py index d254d28010d..9205f4ed998 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_client.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_client.py @@ -260,3 +260,7 @@ class ApiClientTests(unittest.TestCase): def test_parameters_to_url_query_boolean_value(self): result = self.api_client.parameters_to_url_query([('boolean', True)], {}) self.assertEqual(result, "boolean=true") + + def test_parameters_to_url_query_list_value(self): + params = self.api_client.parameters_to_url_query(params=[('list', [1, 2, 3])], collection_formats={'list': 'multi'}) + self.assertEqual(params, "list=1&list=2&list=3") diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index 5aca14639f2..f9ebfbb5402 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -483,7 +483,7 @@ class ApiClient: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, value) for value in v) + new_params.extend((k, str(value)) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/samples/openapi3/client/petstore/python/tests/test_api_client.py b/samples/openapi3/client/petstore/python/tests/test_api_client.py index 972b705872d..8c5a99d3acf 100644 --- a/samples/openapi3/client/petstore/python/tests/test_api_client.py +++ b/samples/openapi3/client/petstore/python/tests/test_api_client.py @@ -245,3 +245,7 @@ class ApiClientTests(unittest.TestCase): def test_parameters_to_url_query_boolean_value(self): result = self.api_client.parameters_to_url_query([('boolean', True)], {}) self.assertEqual(result, "boolean=true") + + def test_parameters_to_url_query_list_value(self): + params = self.api_client.parameters_to_url_query(params=[('list', [1, 2, 3])], collection_formats={'list': 'multi'}) + self.assertEqual(params, "list=1&list=2&list=3")