安装
pip install django-coreapi
pip install pyyaml
-
Schema
# settings.py
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema',
# 总urls.py
from rest_framework.schemas import get_schema_view
schema_view = get_schema_view(title="北网在线 API文档",description="所有API文档")
path('schema/',schema_view), -
coreapi
# settings
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
# 总urls.py
from rest_framework.documentation import include_docs_urls
path('docs/',include_docs_urls(title="北网在线",description="所有API文档")) -
openapi
# settings.py
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema',
from rest_framework.schemas import get_schema_view
path('openapi', get_schema_view(
title="Your Project",
description="API for all things …"
), name='openapi-schema'),