[REQ] Generate python client with using pydantic models
Description
Pydantic offers a clean model api with fast validation. It would be a nice enhancement to generate such models from openapi specs.
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
pydantic coerces data types into the defined types openapi constrains payloads to a set of allowed types and sometimes defines validations that must be done and other schemas (oneaOf/anyOf/allOf discriminated schemas that must also be validated against)
In my opinion coercion goes agains the type constraints that openapi defines because it is changing the type of the payload that you are making assertions against.
That being said, I understand the motivation. The python-fastapi server generator uses pydantic: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python-fastapi.md#metadata
A python client that does not coerce instantiated/received data
Our python-experimental generator does NOT do coercion on received payloads and it has
- robust run time type + validation checking
- oneOf/anyOf/allOf support including imposing type constraints in composed schemas
- type hints for models, properties, endpoint parameters, and responses
I encourage you to give it a look and see if it will meet your needs.
Update: the python-fastapi generator was created which is a server generator and it uses pydantic for model generation So it's not a client but it uses pydantic
Why did you close it? There's no pydantic client yet.
It's such an old issue -- I get feedback once every year or 2 - I've moved on. Feel free to reopen it.
No worries, I was just curious and don't want to reopen if