Skip to content

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

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
keenangraham:fix-autoset-constants-python-code
Aug 4, 2024
Merged

[BUG] [Python] Fix autoset constants Python code for default query string value#19138
wing328 merged 2 commits intoOpenAPITools:masterfrom
keenangraham:fix-autoset-constants-python-code

Conversation

@keenangraham
Copy link
Copy Markdown
Contributor

#16761 introduced Python code to set default header or query string value when OpenAPI parameter is required and has one enum value (have to use --additional-properties autosetConstants=true to activate functionality).

The Python mustache template tries to add parameter to _query_params dict, but query_params is a list:

_query_params: List[Tuple[str, str]] = []
...
# Set client side default value of Query Param "{{baseName}}".
_query_params['{{baseName}}'] = {{#_enum}}'{{{.}}}'{{/_enum}} # wrong

https://github.com/prashant-pant/openapi-generator/blob/21ee1101f5fb310904ae904018cee93d249b796d/modules/openapi-generator/src/main/resources/python/api.mustache#L196-L228

This PR updates mustache template to append query string tuple to _query_string list.

PR checklist

  • [ x] Read the contribution guidelines.
  • [ x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • [x ] Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • [ x] File the PR against the correct branch: master (upcoming 7.6.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • [ x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Copy Markdown
Member

wing328 commented Jul 11, 2024

thanks for the pr

CC
@cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)

@wing328
Copy link
Copy Markdown
Member

wing328 commented Aug 4, 2024

thanks for the PR. let's give it a try

@wing328 wing328 merged commit aa7c62a into OpenAPITools:master Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants