Is your feature request related to a problem? Please describe.
I'm using datamodel-code-generator to generate Python dataclasses from an OpenAPI model. These models have one default response and at least one response using the HTTP status code pattern:
responses:
default:
...
200:
...
Then when running the code generator I would get names like
ResourceGetResponse
- for the default response (usually an error)
ResourceGetResponse1
- for the 200 status response
This might be potentially confusing for consumers of these dataclasses, who blindly import ResourceGetResponse expecting that this corresponds to the 200 status response. We use these dataclasses in our data validation code so this could cause some confusion.
Describe the solution you'd like
Change the code generation to consider the 'current' response in the class name of the model, so instead of:
ResourceGetResponse
- for the default response (usually an error)
ResourceGetResponse1
- for the 200 status response
The code generator would produce:
ResourceGetResponseDefault
- for the default response (usually an error)
ResourceGetResponse200
- for the 200 status response
Describe alternatives you've considered
An alternative would be to edit this manually or after generation time, but we're updating these models quite frequently as we're in development of this new solution.
Additional context
Add any other context or screenshots about the feature request here.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too