diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index 2aa70299a17..8baf78f7a17 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -176,7 +176,7 @@ class {{classname}}: {{#constantParams}} {{#isQueryParam}} # Set client side default value of Query Param "{{baseName}}". - _query_params['{{baseName}}'] = {{#_enum}}'{{{.}}}'{{/_enum}} + _query_params.append(('{{baseName}}', {{#_enum}}'{{{.}}}'{{/_enum}})) {{/isQueryParam}} {{#isHeaderParam}} # Set client side default value of Header Param "{{baseName}}". diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java index b1ec1b42065..57a877d465f 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java @@ -528,5 +528,6 @@ public class PythonClientCodegenTest { .get(Paths.get(output.getAbsolutePath(), "openapi_client", "api", "hello_example_api.py").toString()); assertNotNull(apiFile); assertFileContains(apiFile.toPath(), "_header_params['X-CUSTOM_CONSTANT_HEADER'] = 'CONSTANT_VALUE'"); + assertFileContains(apiFile.toPath(), "_query_params.append(('CONSTANT_QUERY_STRING_KEY', 'CONSTANT_QUERY_STRING_VALUE'))"); } } diff --git a/modules/openapi-generator/src/test/resources/3_0/java/autoset_constant.yaml b/modules/openapi-generator/src/test/resources/3_0/java/autoset_constant.yaml index d8248a85695..bfa6ddf3f17 100644 --- a/modules/openapi-generator/src/test/resources/3_0/java/autoset_constant.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/java/autoset_constant.yaml @@ -21,6 +21,13 @@ paths: type: string enum: - CONSTANT_VALUE + - name: CONSTANT_QUERY_STRING_KEY + in: query + required: true + schema: + type: string + enum: + - CONSTANT_QUERY_STRING_VALUE - name: name in: path required: true @@ -39,4 +46,4 @@ components: type: object properties: message: - type: string \ No newline at end of file + type: string