Exclude URLs from Django REST Swagger

后端 未结 6 2129
再見小時候
再見小時候 2020-12-31 05:27

I have a few URLs that I want to exclude from my REST API documentation. I\'m using Django REST Swagger and the only documentation I can find (https://github.com/marcgibbons

6条回答
  •  遥遥无期
    2020-12-31 05:44

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

    So for example, in your case:

    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")),
                  ...
                  )
    

    and in your settings.py:

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

    This is well described in there

提交回复
热议问题