Skip to content

[Python][Flask] pythonic params #2374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

tomghyselinck
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh, ./bin/security/{LANG}-petstore.sh and ./bin/openapi3/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language. -- @wing328 @taxpon @frol @mbohlool @cbornet @kenjones-cisco @tomplus @Jyhess

Description of the PR

We have an OpenAPI spec file with camelCase (query and path) parameters.
When generating a Python (connexion-based) server those parameters are converted to ("pythonic") snake_case parameters.

During generation of the supporting files there is also an OpenAPI spec file generated for use with connexion. This spec file does not match the original one regarding parameter names.

Especially when defining "query" parameters, the REST interface will be different than the one defined in the original OpenAPI spec file.
Such (query) parameters are incompatible with generated clients (and other server implementations)

Fixes #1671

We have been using this fix some time on a local checkout for generating python-flask server implementations without issues.

Notes

  1. This PR also updates the python-aiohttp but it is untested.
    Please feel free to try it out.

  2. These changes do not limit on query or path parameters and should also work on header and cookie parameters.

@tomghyselinck tomghyselinck marked this pull request as ready for review March 12, 2019 14:28
@wing328 wing328 added this to the 4.0.0 milestone Mar 22, 2019
@wing328 wing328 merged commit f794325 into OpenAPITools:master Mar 24, 2019
@wing328 wing328 changed the title Python flask pythonic params [Python][Flask] pythonic params Mar 24, 2019
@tomghyselinck tomghyselinck deleted the python-flask-pythonic_params branch March 25, 2019 17:22
required: false
schema:
type: integer
format: int32
Copy link
Member

@wing328 wing328 Aug 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll remove this as we want to keep it in sync with petstore.yaml (OAS v2)

Additional test cases should go to https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml instead

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.

[BUG][Python-Flask] camelCase path parameters are not converted to snake_case
2 participants