create pydantic model class from schema
Closed this issue · 2 comments
shaojun commented
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
create a model class (type[BaseModel]
) by schema
Describe alternatives you've considered
Additional context
I see there's create_model
function that allow pass in json string and get a model class (type[BaseModel]
), like:
from pydantic import BaseModel, create_model
pydantic_model_type = create_model(
'model_from_air', '{"name":"foo", "age":99}')
koxudaxi commented
I'm sorry for my slow response.
I guess your use case will match the content.
https://koxudaxi.github.io/datamodel-code-generator/using_as_module/
koxudaxi commented
also, the comment may help you.
#278 (comment)