- 我们需要api文档来叙述api的内容
- 我们会经常做出改动
- 我们需要一个api文档来帮助检测功能
coreapi
- 好看的api文档
- pip install coreapi
纲要文档
# urls.py
from rest_framework.schemas import get_schema_view
urlpattern = [
url(r'^schema/', get_schema_view(title='文档-API'))
]
改进为:API文档
from rest_framework.documentation import include_docs_urls
urlpattren = [
url(r'docs/', include_docs_urls(title='医院-API'))
]
Swagger
- 多编程语言通用的API文档
- pip install django-rest-swagger
# setting.py
INSTALLED_APPS = [
...
'rest_framework_swagger'
]
# urls.py
from rest_framework_swagger.views import get_swagger_view
urlpatterns = [
url(r'docs/', get_swagger_view(title='病人-API'))
]