Hello everyone!
I have a bunch of ReST APIs in production under my belt, but most of them are documented manually. I must say it is absolutely tiring writing api documentation for each release. Having a new project at hand, I want to utilize the OpenAPI schema and possibly have an autogenerated Swagger documentation.
I built two prototypes in the past week:
- DRF with drf-yasg
- Django Ninja
For #1, I managed to setup the initial endpoints with some medium effort. The endpoint level customization is nice. But my @swagger_auto_schema
decorator lines were balooning in LOCs to the point that the decorator eclipses the logic inside the view (which might not be a bad thing if following “dumb views” pattern).
For #2, the setup is pretty minimal and I’m writing expressive code ala-Flask. But then I came to the point of realizing that I’m repeating logic with my Schema
objects and my DRF Serializers
. And any complex validation requires me to stoop down to the pydantic
level, which is just too much for my taste as compared to the simple definition of a Serializer class.
For the meantime, I’m considering going back to #1 since it’s pretty much “vanilla” DRF with a little bit of cruft here and there. I’m curious what the Django community’s tool-set of choice for these kinds of projects.
Thank you and stay safe!