根据正在运行的URL,在运行时间动态更改Swagger UI``server'
我正在使用Swagger
接口来测试我的API端点。我在两个不同的服务器上运行了此
- 产品服务器
https://example.co.app
- 登台服务器
https://example-staging.co.co.app
我管理为了在config.js
文件中选择您要使用的服务器中的下拉列表以选择您要使用的
servers: [
{
url: 'https://example.co.app',
description: 'prod server'
},
{
url: 'https://example-staging.co.app',
description: 'staging server'
}
]
服务器默认情况下,服务器是列表中的第一个。
我想根据实际运行的服务器在运行时进行默认动态。
这是否可以使用Swagger配置?
I am using a swagger
interface to test my API endpoints. I Have this running on two different servers
- A production server
https://example.co.app
- A staging server
https://example-staging.co.app
I managed to make a dropdown list to select the server you want to use like so in a via options
in a config.js
file:
servers: [
{
url: 'https://example.co.app',
description: 'prod server'
},
{
url: 'https://example-staging.co.app',
description: 'staging server'
}
]
This works but will always use prod server
by default since it is the first one in the list.
I would like to make the default dynamic at run time based on what server It is actually running in.
Is this possible with swagger configurations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论