Calling datamodel-code-generator programatically
See original GitHub issueBackground Information
I would like to use the datamodel-code-generator in a program which automates the extraction of data-models of an existing API documentation. Unfortunately the API documentation is not in a JSON-format, but a simple Website. So the plan is to parse the Website and create a JSON Schema with the information I gained.
Actual Feature Request
I plan to generate the Pydantic Models with the extracted JSON schema. The question is if it is possible to use datamodel-code-generator programmatically.
# I generate the json schema
json_schema: str = extract_from_website()
# And pass it to the datamodel-code-generator which in turn generates the pydantic_models
pydantic_models: str = generate(json_schema, ...some_args)
# or whatever fits best
I had a quick look at the code, but the generate function does not look like it is intended to be used that way. So would it be possible to modify it in a way so you can use the library from python and not just as a command line tool?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
API Client · Issue #40 · koxudaxi/datamodel-code-generator
I would set the first scope is to create code-generator for server-side in the next project. And, a second is to create code-generator...
Read more >datamodel-code-generator - GitHub Pages
This code generator creates pydantic model from an openapi file and others.
Read more >Code Generation - pydantic
The datamodel-code-generator project is a library and command-line utility to generate pydantic models from just about any data source, ...
Read more >Tutorial: Create a more complex data model for an ASP.NET ...
In this tutorial you add more entities and relationships and you customize the data model by specifying formatting, validation, and database ...
Read more >Generate Pydantic Models from JSON in the browser : r/Python
Full credit for the actual model creation goes to the datamodel-code-generator project!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks that looks great
Thanks for the quick reply. That looks really great and does not feel to much like a workaround.
And thanks for the your lib which really saves me a lot of time