mirror of
https://github.com/hequan2017/seal.git
synced 2026-05-05 20:55:40 +08:00
v0.5.1 增加API文档
This commit is contained in:
@@ -151,3 +151,4 @@ Werkzeug==0.14.1
|
||||
WTForms==2.2.1
|
||||
zope.deprecation==4.4.0
|
||||
zope.interface==4.6.0
|
||||
django-rest-swagger
|
||||
@@ -50,6 +50,7 @@ INSTALLED_APPS = [
|
||||
'django_filters',
|
||||
'graphene_django',
|
||||
'channels',
|
||||
'rest_framework_swagger',
|
||||
]
|
||||
|
||||
GRAPHENE = {
|
||||
@@ -267,3 +268,34 @@ CHANNEL_LAYERS = {
|
||||
|
||||
# 配置ASGI
|
||||
ASGI_APPLICATION = "seal.routing.application"
|
||||
|
||||
SWAGGER_SETTINGS = {
|
||||
# 基础样式
|
||||
# 'SECURITY_DEFINITIONS': {
|
||||
# "basic": {
|
||||
# 'type': 'basic'
|
||||
# }
|
||||
# },
|
||||
'USE_SESSION_AUTH': True,
|
||||
'SECURITY_DEFINITIONS': {
|
||||
'api_key': {
|
||||
'type': 'apiKey',
|
||||
'in': 'header',
|
||||
'name': 'authorization'
|
||||
}
|
||||
},
|
||||
# 如果需要登录才能够查看接口文档, 登录的链接使用restframework自带的.
|
||||
# 'LOGIN_URL': '/api/v1/login/',
|
||||
# 'LOGOUT_URL': 'rest_framework:logout',
|
||||
# 'DOC_EXPANSION': None,
|
||||
# 'SHOW_REQUEST_HEADERS':True,
|
||||
# 'USE_SESSION_AUTH': True,
|
||||
# 'DOC_EXPANSION': 'list',
|
||||
# 接口文档中方法列表以首字母升序排列
|
||||
'APIS_SORTER': 'alpha',
|
||||
# 如果支持json提交, 则接口文档中包含json输入框
|
||||
'JSON_EDITOR': True,
|
||||
# 方法列表字母排序
|
||||
'OPERATIONS_SORTER': 'alpha',
|
||||
'VALIDATOR_URL': None,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ from rest_framework.authtoken import views
|
||||
from rest_framework.documentation import include_docs_urls
|
||||
from graphene_django.views import GraphQLView
|
||||
from seal.schema import schema
|
||||
from rest_framework_swagger.views import get_swagger_view
|
||||
|
||||
schema_view = get_swagger_view(title='海豹 API 文档')
|
||||
|
||||
API_TITLE = '海豹 API 文档'
|
||||
API_DESCRIPTION = '海豹 API 文档'
|
||||
@@ -20,6 +23,7 @@ urlpatterns = [
|
||||
path('api/token', views.obtain_auth_token),
|
||||
path('api/docs/', include_docs_urls(title=API_TITLE, description=API_DESCRIPTION, authentication_classes=[],
|
||||
permission_classes=[])),
|
||||
path('api/docs2/', schema_view, name="docs"),
|
||||
path('graphql/', GraphQLView.as_view(graphiql=True, schema=schema)),
|
||||
|
||||
path('sql/', include('sql.urls', namespace='sql')),
|
||||
|
||||
Reference in New Issue
Block a user