如何从 Django 内置 API 文档中排除 rest-auth 端点?
How can I exclude rest-auth endpoint from the Django built-in API documentation?
要在 Django 文档中隐藏端点,只需将 @schema(None)
添加到 GenericAPIView
,但是我对这两个网址有疑问:
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
我无法添加 @schema(None)
装饰器,因为我没有为这些网址声明视图。有什么解决办法吗?
我想到的解决方案:
(vf, app_name, namespace) = include('rest_auth.urls')
vf.LoginView = schema(None)(vf.LoginView)
vf.LoginView = schema(None)(vf.LogoutView)
vf.LoginView = schema(None)(vf.PasswordChangeView)
vf.LoginView = schema(None)(vf.PasswordResetConfirmView)
vf.LoginView = schema(None)(vf.PasswordResetView)
vf.LoginView = schema(None)(vf.UserDetailsView)
(vf_registration, app_name_registration, namespace_registration) = include('rest_auth.registration.urls')
vf_registration.RegisterView = schema(None)(vf_registration.RegisterView)
vf_registration.TemplateView = schema(None)(vf_registration.TemplateView)
vf_registration.VerifyEmailView = schema(None)(vf_registration.VerifyEmailView)
urlpatterns = [
url(r'^rest-auth/', (vf, app_name, namespace)),
url(r'^rest-auth/registration/', (vf_registration, app_name_registration, namespace_registration)),
]
要在 Django 文档中隐藏端点,只需将 @schema(None)
添加到 GenericAPIView
,但是我对这两个网址有疑问:
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
我无法添加 @schema(None)
装饰器,因为我没有为这些网址声明视图。有什么解决办法吗?
我想到的解决方案:
(vf, app_name, namespace) = include('rest_auth.urls')
vf.LoginView = schema(None)(vf.LoginView)
vf.LoginView = schema(None)(vf.LogoutView)
vf.LoginView = schema(None)(vf.PasswordChangeView)
vf.LoginView = schema(None)(vf.PasswordResetConfirmView)
vf.LoginView = schema(None)(vf.PasswordResetView)
vf.LoginView = schema(None)(vf.UserDetailsView)
(vf_registration, app_name_registration, namespace_registration) = include('rest_auth.registration.urls')
vf_registration.RegisterView = schema(None)(vf_registration.RegisterView)
vf_registration.TemplateView = schema(None)(vf_registration.TemplateView)
vf_registration.VerifyEmailView = schema(None)(vf_registration.VerifyEmailView)
urlpatterns = [
url(r'^rest-auth/', (vf, app_name, namespace)),
url(r'^rest-auth/registration/', (vf_registration, app_name_registration, namespace_registration)),
]