簡體   English   中英

如何從 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)裝飾器,因為我沒有為這些 url 聲明視圖。 任何想法如何解決它?

我想出的解決方案:

(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)),
]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM