OpenAPITools / OpenAPITools/openapi-generator
[REQ] [python-fastapi] Need support for generating Strict Types in pydantic models as part of python-fastapi generator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
As part of the python-fastapi generator, the generated models inherit from the pydantic BaseModel class.
But, the data types used in the generated models currently support basic types and not Strict Types.
Due to this, as mentioned in this issue, pydantic will try to parse values into the shape specified by the model, including coercing the types.
Describe the solution you'd like
The openapi-generator can add an option to the python-fastapi generator, where the generated models will use Strict Types, instead of plain types.
Describe alternatives you've considered
Currently, the generated models need to be edited manually to convert from Types to Strict Types.
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 the python-fastapi generator and inspect how generated models inherit from pydantic BaseModel and map OpenAPI types. Define the generator option and expected Strict Types behavior, then verify that generated models use strict types instead of plain types without requiring manual edits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100