12-1 文档-DRF生成文档

目录:

  • API文档
  • 路由配置
  • 效果展示

一、API文档

 DRF给我提供了自动生成API文档的功能,大大节省了些开发的文档的时间。安装:

pip install coreapi 

二、路由配置

说明:我们需要在根级路由下配置路由,当然你在 子路由下配置也是可以的,这个就要看你自己了。

from django.contrib import admin
from django.urls import path, include

from rest_framework.documentation import include_docs_urls   #导入 api文档工具类

urlpatterns = [
    path('admin/', admin.site.urls),
    path('docs/', include_docs_urls(title="测试平台接口文档"))   #配置api文档路由
]

三、效果展示

3.1、首页

说明:访问:http://127.0.0.1:8000/docs/

3.2、API文档使用说明

说明:API接口的使用说明

posted @ 2020-05-07 11:17  帅丶高高  阅读(438)  评论(0)    收藏  举报