【问题标题】:Swagger UI ignores query-param "url=" and opens PetStore insteadSwagger UI 忽略查询参数“url=”并改为打开 PetStore
【发布时间】:2022-06-28 17:18:55
【问题描述】:
在将 Swagger UI 从 3.x 更新到 4.x 后,通过 application-url 中断中的参数加载我的自定义架构。
在https://example.com/swagger/index.html?url=https://example.com/docs/simrws.yaml 加载我的自定义规格之前。现在只加载默认示例Swagger Petstore。
控制台上没有错误。 docs 说,配置 Swagger UI 的第四种方法是使用 URL-params。
【问题讨论】:
标签:
configuration
swagger-ui
【解决方案1】:
在V4.1.3中添加了一个破security-feature:
root@server:/opt/swagger-ui-git# git diff v4.1.2 v4.1.3 src/core/index.js
diff --git a/src/core/index.js b/src/core/index.js
index 677e3786..621b095f 100644
--- a/src/core/index.js
+++ b/src/core/index.js
@@ -77,6 +77,7 @@ export default function SwaggerUI(opts) {
+ queryConfigEnabled: false,
@@ -108,7 +109,7 @@ export default function SwaggerUI(opts) {
- let queryConfig = parseSearch()
+ let queryConfig = opts.queryConfigEnabled ? parseSearch() : {}
您会在上面链接的文档中找到提到的内容。
编辑文件 src/core/index.js 以将以下行从 false 更改为 true 以恢复旧行为:
queryConfigEnabled: true,
由于这是一个安全修复,因此可能有比仅仅恢复到旧行为更好的方法。