OpenAPITools / OpenAPITools/openapi-generator
[BUG] [PYTHON] Duplicate parameter name causes syntax error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
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
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the linked Hydra OpenAPI declaration and the shown openapi-generator command using the Python generator. Start by comparing Python-flask handling of ensureUniqueParameters with the generated constructor parameters. Done means the generator either reports the duplicate parameter or produces valid Python with unique parameter names, backed by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100