使用coreapi自动生成api接口文档

使用coreapi自动生成api接口文档

安装第三方扩展模块

pip install coreapi

在路由中配置:

from rest_framework.documentation import include_docs_urls

urlpatterns = [
    # 自动生成接口文档
    path('docs/',include_docs_urls(title='surpass接口测试'))
]

新版需要在settings.py中配置:

REST_FRAMEWORK = {
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}
原文地址:https://www.cnblogs.com/surpass123/p/13305485.html