自动生成接口文档coreapi

drf-yasg只能用于drf

去看官方文档

2 coreapi

pip install coreapi

2.1 配置路由

from rest_framework.documentation import include_docs_urls

urlpatterns = [
    ...
    path('docs/', include_docs_urls(title='站点页面标题'))
]

2.2 drf配置

#AttributeError: 'AutoSchema' object has no attribute 'get_link'
REST_FRAMEWORK = {
 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
    # 新版drf schema_class默认用的是rest_framework.schemas.openapi.AutoSchema

}


posted @ 2024-04-18 11:38  沉岩  阅读(9)  评论(0编辑  收藏  举报