问题
I have large amount of API endpoints written in django-rest-framework
and it keeps increasing and updating. How can I create & maintain API documentation that should be up-to-date?
My current version is
- Create
swagger.yaml
file and somehow auto generate everytime any endpoint changes. - Then use this file as an input to readme.io, ReDoc or other alternatives to provide visualization to external folks.
If you have an experience on this or any similar solution, please share I really appreciate it!
回答1:
Yes, you could take a look at drf-yasg:
drf-yasg docs
The quickstart shows how 4 endpoints are created including one which outputs swagger.yaml file. Once you have included drf-yasg, you can navigate to:
http://localhost:8000/swagger.yaml
which will then allow you to save the swagger docs to disk.
来源:https://stackoverflow.com/questions/51343394/does-django-rest-framework-have-third-party-apps-to-auto-generate-swagger-yaml-f