如何从Django内置API文档中排除rest-auth端点?

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 three urls:

url(r'^swagger/', schema_view),
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?

评论
记忆狠清晰
记忆狠清晰

Yes, you can just call the schema(None)(…) function, this is in essence what a decorator does:

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

装饰器基本上将函数,类等传递给函数,然后将结果分配给您最初使用的标识符。

点赞
评论