Use Django Ninja experimentally for feedback APIs
About Django Ninja
OpenAPI support has proven to be very useful in VISIT for auto-generating request hooks for the frontend. Additionally, having Pydantic types for input and output would guarantee safety much more than our current approach of manually doing request.DATA[key].
I've evaluated a few libraries (DRF, Django Ninja, Django Shinobi, Django's native REST class view) and decided that Django Ninja is best because it:
- is the most-recommended option on the internet at the momemnt
- requires least changes to an existing Django application while delivering tons of value
- is actively maintained and used by industry
- it's not clunky and hard to understand with weird OOP classes (see
Documentsat the moment for an example of that) - it puts together declaration of routes with the view function, no more forgetting
It can do incremental migration of endpoints, and it fits seamlessly with an existing Django app. It also uses Pydantic under the hood.
About this MR
This merge request is a sort of proposal for trying Django Ninja out experimentally, by migrating only the three (3) /api/feedback endpoints. If we exclude uv.lock, the diff is only +79, -58 lines changed!
Unit tests pass and all other routes are unaffected.
- File structure wise,
url.pyandviews.pywere merged into a newapi.py - OpenAPI documentation is at
/api/docs - OpenAPI JSON description is at
/api/openapi.json
Open to thoughts!
