简体   繁体   中英

How can I exclude rest-auth endpoint from the Django built-in API documentation?

To hide the endpoint in the Django documentation just @schema(None) has to be added for example to GenericAPIView , however I have a problem with these two urls:

url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),

I am not able to add @schema(None) decorator because I do not have declared views for these urls. Any ideas how to work it around?

The solution that I came up with:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM