Exclude URLs from Django REST Swagger(从 Django REST Swagger 中排除 URL)
问题描述
我想从我的 REST API 文档中排除一些 URL.我正在使用 Django REST Swagger 和我能找到的唯一文档 (https://github.com/marcgibbons/django-rest-swagger) 并没有真正告诉我太多.settings.py 中有 SWAGGER_SETTINGS 的exclude_namespaces"部分,但没有真正的解释或示例说明如何使用它.
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/django-rest-swagger) doesn't really tell me much. There is the "exclude_namespaces" part of SWAGGER_SETTINGS in settings.py, but there is no real explanation or example of how to use this.
简单地说,我想从文档中排除以以下内容开头的所有 URL:
Simply put, I want to exclude any URLs from the docs that start with the following:
/api/jobs/status/
/api/jobs/parameters/
我该怎么做呢?
提前感谢您提供的任何帮助:P
Thanks in advance for any help offered :P
推荐答案
要排除的命名空间是您的 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
}
这在那里有很好的描述
这篇关于从 Django REST Swagger 中排除 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Django REST Swagger 中排除 URL


基础教程推荐
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 筛选NumPy数组 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01