drf文档

swagger

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# pip install django-rest-swagger
# pip install coreapi
INSTALLED_APPS = [
...
'rest_framework_swagger'
]
REST_FRAMEWORK = {
# api接口文档配置
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='API 接口文档')

urlpatterns += [
path('docs1/', schema_view, name='docs1'), # 线上环境,干掉
]
# 修改下源码即可

自带api文档

1
2
3
4
5
6
7
8
9
10
# pip install coreapi
REST_FRAMEWORK = {
# api接口文档配置
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}
from rest_framework.documentation import include_docs_urls

urlpatterns = [
path(r'docs/', include_docs_urls(title='STAR PAAS')),
]
分享到