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


基础教程推荐
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 包装空间模型 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 求两个直方图的卷积 2022-01-01