OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.44k stars 6.48k forks source link

[BUG] [PYTHON] Duplicate parameter name causes syntax error #8586

Open rossjones opened 3 years ago

rossjones commented 3 years ago

Bug Report Checklist

Description

When generating a client from the OpenAPI file below using the Python generator, the constructor of a class has both a parameter named args, and a parameter named *args.

This causes a syntax error.

What I expected: Either an error to be raised, or the none *args parameter to be renamed to ensure uniqueness.

What happened: The client was generated 'successfully' but at run time I receive a runtime error

openapi-generator version

5.0.0

OpenAPI declaration file content or url

https://raw.githubusercontent.com/ory/sdk/b8fc063b15e81ae73f824fa23345a372008142ed/spec/hydra/v1.9.2.json

Generation Details
projectName: ory-${PROJECT}-client
packageName: ory_${PROJECT}_client
packageVersion: $VERSION
library: urllib3
packageUrl: https://github.com/ory/sdk

source: https://github.com/ory/sdk/blob/b8fc063b15e81ae73f824fa23345a372008142ed/config/client/python.yml

Steps to reproduce
git clone https://github.com/ory/sdk.git && cd sdk 
openapi-generator-cli generate -i "spec/hydra/v1.9.2.json" \
    -g python-flask \
    -o python-client-output \
    --git-user-id x \
    --git-repo-id x \
    --git-host github.com \
    -c ./config/client/python.yml
Related issues/PRs

This was originally reported at ory/sdk as https://github.com/ory/sdk/issues/56

Suggest a fix

The Python-flask server generator appears to have a parameter ensureUniqueParameters which sounds like this type of thing this may require.

auto-labeler[bot] commented 3 years ago

šŸ‘ Thanks for opening this issue! šŸ· I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

wing328 commented 3 years ago

Another way is to whitelist args and rename it to param_args or something else to avoid duplicated parameter names.

rossjones commented 3 years ago

@wing328 thanks for the suggestion. I couldn't find anything in the docs about configuring a whitelist, is there a phrase or term that I should be searching for which'll give me a pointer?