[BUG] [Python] Fix autoset constants Python code for default query string value (#19138)

* _query_params is list, not dict

* Add test
This commit is contained in:
keenangraham 2024-08-04 03:13:53 -07:00 committed by GitHub
parent aaeed0f5bd
commit aa7c62abb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View File

@ -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}}".

View File

@ -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'))");
}
}

View File

@ -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
type: string