gpt4 book ai didi

swagger - 如何在 SwaggerUIBundle 中设置请求拦截器?

转载 作者:行者123 更新时间:2023-12-03 18:40:38 30 4
gpt4 key购买 nike

在我们的 swagger.json 我们将 basePath 设置为 /api 但是,当应用程序部署在 docker 容器中时,上下文路径不是/api。这可能是不同的事情,我们不知道它是什么,所以我们不能对其进行硬编码。

我正在尝试设置 请求拦截器 根据以下指南,为了捕获请求并可能修改 url 路径:

https://swagger.io/docs/swagger-tools/#customization-36

不过好像请求拦截器 正在被忽视。这可能吗?如果没有,如何在运行时设置正确的路径?

这是我在 中的代码index.html

    window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: "../api-docs/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
requestInterceptor: function(request) {
window.alert(request);
},
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})

window.ui = ui

}

我们正在使用 Swagger 2.0

最佳答案

here 升级到最新版本,或更新您的节点包。我遇到了同样的问题,因为我之前下载了发行版 requestInterceptor添加了支持。

关于swagger - 如何在 SwaggerUIBundle 中设置请求拦截器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46485621/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com