-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python): add --pydantic-base-model option #2604
Conversation
|
@zhao004 This is a pull request - code and changes included here are not part of the application until they are merged. |
When can the merger be completed? |
Is there a timeline for this mr? We are really looking forward to this feature |
👍 |
1 similar comment
+1 |
@alpoi-x @zhao004 @inferrinizzard Any chance of getting this merged? |
Will take a look in the next few days 👍 |
Is there an available screenshot or side-by-side example of the output with this new option compared against Python dataclasses ? |
@inferrinizzard |
@inferrinizzard Does the quicktype.io website get these updates? Seems to be pointing to super old python versions. |
Description
Adds a python option
pydantic-base-model
, which will generate classes inheriting pydantic's BaseModel.Related Issue
#1474
Motivation and Context
Pydantic is a commonly used python module for defining schemas and dataclasses with validation. It is used in FastApi. It is a nice alternative to the builtin
dataclasses
module.Previous Behaviour / Output
Quicktype generates standard classes or dataclasses (3.7+) for python
New Behaviour / Output
With the
--pydantic-base-model
option, it generates pydantic BaseModel classesHow Has This Been Tested?
Built and generated python from a schema, with and without
--pydantic-base-model
option.Without the option included
from dataclasses import dataclass
and@dataclass
With the option instead included
from pydantic import BaseModel
andclass Example(BaseModel)
Screenshots (if appropriate):