OpenAPITools / OpenAPITools/openapi-generator
Incorrect code mapping when "Default" directive is used.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hello! I'm trying out the new 6.0 release and noticed it generated some invalid Python-FastAPI code. Here is the offending line of code:
And here is the OpenAPI.yaml that was used as input:
And lastly here is the invalid python code that was generated:
responses={
200: {"model": Pet, "description": "pet response"},
200: {"model": Error, "description": "unexpected error"},
},
In the openapi.yaml file there was a response model for status code 200 and a response model for "Default" (everything else). The code generator interpreted this "Default" as a 200 which resulted in a python dictionary with 2x keys for 200, which is invalid.
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
Start with modules/openapi-generator/src/main/resources/python-fastapi/api.mustache at the referenced response mapping and compare it with the Default response in petstore-expanded.yaml at line 51. Regenerate the Python-FastAPI output from that specification and confirm the result preserves the explicit 200 response while handling Default without producing duplicate dictionary keys.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, java, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100