mirror of https://github.com/jumpserver/jumpserver
perf: 优化 docs swagger,不再要求debug
parent
ff428b84f9
commit
0813cff74f
|
@ -38,11 +38,7 @@ app_view_patterns = [
|
||||||
re_path(r'flower/(?P<path>.*)', views.celery_flower_view, name='flower-view'),
|
re_path(r'flower/(?P<path>.*)', views.celery_flower_view, name='flower-view'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
if settings.XPACK_ENABLED:
|
if settings.XPACK_ENABLED:
|
||||||
app_view_patterns.append(
|
|
||||||
path('xpack/', include('xpack.urls.view_urls', namespace='xpack'))
|
|
||||||
)
|
|
||||||
api_v1.append(
|
api_v1.append(
|
||||||
path('xpack/', include('xpack.urls.api_urls', namespace='api-xpack'))
|
path('xpack/', include('xpack.urls.api_urls', namespace='api-xpack'))
|
||||||
)
|
)
|
||||||
|
@ -54,7 +50,6 @@ apps = [
|
||||||
'flower', 'luna', 'koko', 'ws', 'docs', 'redocs',
|
'flower', 'luna', 'koko', 'ws', 'docs', 'redocs',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.IndexView.as_view(), name='index'),
|
path('', views.IndexView.as_view(), name='index'),
|
||||||
path('api/v1/', include(api_v1)),
|
path('api/v1/', include(api_v1)),
|
||||||
|
@ -67,19 +62,17 @@ urlpatterns = [
|
||||||
path('ui/', views.UIView.as_view()),
|
path('ui/', views.UIView.as_view()),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# 静态文件处理路由
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
|
||||||
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||||
|
|
||||||
js_i18n_patterns = [
|
# js i18n 路由文件
|
||||||
|
urlpatterns += [
|
||||||
path('core/jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
|
path('core/jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
|
||||||
]
|
]
|
||||||
urlpatterns += js_i18n_patterns
|
|
||||||
|
|
||||||
handler404 = 'jumpserver.views.handler404'
|
# docs 路由
|
||||||
handler500 = 'jumpserver.views.handler500'
|
urlpatterns += [
|
||||||
|
|
||||||
if settings.DEBUG:
|
|
||||||
urlpatterns += [
|
|
||||||
re_path('^api/swagger(?P<format>\.json|\.yaml)$',
|
re_path('^api/swagger(?P<format>\.json|\.yaml)$',
|
||||||
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
||||||
re_path('api/docs/?', views.get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"),
|
re_path('api/docs/?', views.get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"),
|
||||||
|
@ -89,7 +82,7 @@ if settings.DEBUG:
|
||||||
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
||||||
path('api/docs/v2/', views.get_swagger_view("v2").with_ui('swagger', cache_timeout=1), name="docs"),
|
path('api/docs/v2/', views.get_swagger_view("v2").with_ui('swagger', cache_timeout=1), name="docs"),
|
||||||
path('api/redoc/v2/', views.get_swagger_view("v2").with_ui('redoc', cache_timeout=1), name='redoc'),
|
path('api/redoc/v2/', views.get_swagger_view("v2").with_ui('redoc', cache_timeout=1), name='redoc'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# 兼容之前的
|
# 兼容之前的
|
||||||
|
@ -98,3 +91,5 @@ old_app_pattern = r'^{}'.format(old_app_pattern)
|
||||||
urlpatterns += [re_path(old_app_pattern, views.redirect_old_apps_view)]
|
urlpatterns += [re_path(old_app_pattern, views.redirect_old_apps_view)]
|
||||||
|
|
||||||
|
|
||||||
|
handler404 = 'jumpserver.views.handler404'
|
||||||
|
handler500 = 'jumpserver.views.handler500'
|
||||||
|
|
|
@ -76,9 +76,8 @@ def get_swagger_view(version='v1'):
|
||||||
patterns = api_v1_patterns
|
patterns = api_v1_patterns
|
||||||
schema_view = get_schema_view(
|
schema_view = get_schema_view(
|
||||||
api_info,
|
api_info,
|
||||||
public=True,
|
|
||||||
patterns=patterns,
|
patterns=patterns,
|
||||||
permission_classes=(permissions.AllowAny,),
|
permission_classes=(permissions.IsAuthenticated,),
|
||||||
)
|
)
|
||||||
return schema_view
|
return schema_view
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue