Especially when you have one dominant language that most of your code is interfacing with, having the the interface be hand written with idiomatic code for that language is a lot nicer than everyone having to work with auto-generated code that is often not as nice.
Shameless plug: https://pyotr.readthedocs.io ;)
Please keep in mind that it is still quite a new project (less than two years old); any issue reports and comments are more than welcome! :)
Possibly, but I think that Python code generation is kind of pointless. CG makes sense with compiled languages, but in Python everything can be constructed on the fly at runtime, without any loss of performance.
Second, types can be constructed on the fly as well. Agreed, they will not show up in an IDE, but a) they can (and should!) be unit tested, and b) while I do value editor type-checking I value my time, and streamlined process (i.e. not having to have the extra step of code generation each time I change the spec) much more.
And finally, if you version both spec and the generated code you run into a danger of them diverging without realising. If you absolutely must have the code generation, make sure not to commit the generated code, and rebuild each time you change the spec.
This is an important distinction and might not be what you want.
Using spec first API design makes more sense IMHO. You first spec your API (Either in OpenAPI or GRPC or whatever Interface Definition Language you use). This allows Backend and Frontend developers to change the API definition.
From there you generate all type-save model objects, client and server stubs, and fill in the implementation with full type hinting.
At my current company, we wrote OpenAPI specs first, no need to know Python. And use https://openapi-generator.tech/ to generate both the Python server, python client and typescript client. We're looking into generate Kotlin and Swift clients too...
I'm a big proponent of spec first API design. It's much cheaper to agree on a spec first before you start coding.
But it depends on what you are doing.
Personally I like GRPC best, since the code generators are top notch.
Very good article on this principle:
https://medium.com/apis-and-digital-transformation/openapi-a...
First, stop writing interface code for your APIs by hand. Second, stop writing interface code for your APIs by hand. Third, stop writing interface code for your APIs by hand.
We're living in 2021... Every time I see somebody manually mapping an objects to a JSON dictionary I'm crying in the inside. It's like writing machine code by hand.