且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 Django REST Swagger 中排除 URL

更新时间:2023-02-23 21:00:08

要排除的命名空间是您的 urls.py 中定义的命名空间.

the namespaces to exclude are the one defined in your urls.py.

例如,在你的情况下:

urls.py:

internal_apis = patterns('',
                     url(r'^/api/jobs/status/',...),
                     url(r'^/api/jobs/parameters/',...),
                     )

urlpatterns = urlpatterns + patterns('',
              url(r'^', include(internal_apis, namespace="internal_apis")),
              ...
              )

在你的 settings.py 中:

and in your settings.py:

SWAGGER_SETTINGS = {
    "exclude_namespaces": ["internal_apis"],    #  List URL namespaces to ignore
}

这在那里有很好的描述