datamodel-code-generator
typer
Our great sponsors
datamodel-code-generator | typer | |
---|---|---|
9 | 86 | |
2,221 | 13,353 | |
- | - | |
9.4 | 6.7 | |
7 days ago | 1 day ago | |
Python | Python | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
datamodel-code-generator
-
tRPC – Move Fast and Break Nothing. End-to-end typesafe APIs made easy
Like generating pydantic models or dataclasses for an OpenAPI schema? I haven't needed to go in that direction myself, but this[0] looks promising!
Apologies if I've misunderstood your comment
-
OpenAPI v4 Proposal
I'm sorry, but you have completely misunderstood the purpose of Open API.
It is not a specification to define your business logic classes and objects -- either client or server side. Its goal is to define the interface of an API, and to provide a single source of truth that requests and responses can be validated against. It contains everything you need to know to make requests to an API; code generation is nice to have (and I use it myself, but mainly on the server side, for routing and validation), but not something required or expected from OpenAPI
For what it's worth, my personal preferred workflow to build an API is as follows:
1. Build the OpenAPI spec first. A smaller spec could easily be done by hand, but I prefer using a design tool like Stoplight [0]; it has the best Web-based OpenAPI (and JSON Schema) editor I have encountered, and integrates with git nearly flawlessly.
2. Use an automated tool to generate the API code implementation. Again, a static generation tool such as datamodel-code-generator [1] (which generates Pydantic models) would suffice, but for Python I prefer the dynamic request routing and validation provided by pyapi-server [2].
3. Finally, I use automated testing tools such as schemathesis [3] to test the implementation against the specification.
[1] https://koxudaxi.github.io/datamodel-code-generator/
-
Create Pydantic datamodel from huge JSON file with local datamodel-code-generator
The site also provide a link to the github repo of the underlying program.
-
PSA: I think this JSON to Pydantic converter is extremely useful for boilerplate model creation
Not sure who owns/hosts the site, but its based on this github repo.
-
My top python library
That's what datamodel-code-generator propose.
-
I use attrs instead of pydantic
had generally good experience creating typed wrappers for api's with json-schema-to-pydantic[0] converter
typer
- Copilot for your GitHub stars
-
Things I've learned about building CLI tools in Python
I have been using Typer on every one of my CLI projects which uses Click under the hood. The documentation is fantastic, the CLI app it produces looks great and lets you create things quickly. I high recommend it.
-
Things to do with standalone script
Adding CLI capabilities. My preferred library here is typer.
-
The different uses of Python type hints
Similarly for Typer, which is literally "the FastAPI of CLIs"[1]. Handy to type your `main` parameters and have CLI argument parsing. For more complicated cases, it's a wrapper around Click.
-
Command line parser library, which one do you like the most, regardless of language?
interesting that you hate python, but love Click. Did you try Typer which uses Click underneath?
-
I made a file manager in python
Try to make it into a command line tool? check https://typer.tiangolo.com/ for example
- How does "python3 *file* -*letter* work?
-
How to make a CLI?
I used this template repo to make a bash cli https://github.com/SierraSoftworks/bash-cli then I made a brew formula to make it installable. It provide a nice way to make a cli with nested commands like git. As others mentioned other languages like python have great support for making nice clis see https://typer.tiangolo.com/ for an example framework in python. I chose bash because packaging a python cli for a private brew package is a pain and 99% of what I needed the cli to do was inkoke other clis, so bash made sense for my case.
-
I am sick of writing argparse boilerplate code, so I made "duckargs" to do it for me
Very cool. I’ve been using Typer lately. Easy to give a library a cli without too much boilerplate.
-
Just released my much-improved YouTube archiver as v1.2 🎉🎉
Check out Typer for the command line tooling, might make it a bit easier to maintain later on!
What are some alternatives?
click - Python composable command line interface toolkit
Python Fire - Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
Gooey - Turn (almost) any Python command line program into a full GUI application with one line
sqlmodel - SQL databases in Python, designed for simplicity, compatibility, and robustness.
rich - Rich is a Python library for rich text and beautiful formatting in the terminal.
python-prompt-toolkit - Library for building powerful interactive command line applications in Python
cement - Application Framework for Python
pydantic - Data validation using Python type hints
docopt - Pythonic command line arguments parser, that will make you smile
pydantic-factories - Simple and powerful mock data generation using pydantic or dataclasses
fastapi - FastAPI framework, high performance, easy to learn, fast to code, ready for production
clint - Python Command-line Application Tools