根据正在运行的URL,在运行时间动态更改Swagger UI``server'

发布于 2025-01-30 02:51:09 字数 548 浏览 2 评论 0原文

我正在使用Swagger接口来测试我的API端点。我在两个不同的服务器上运行了此

  1. 产品服务器https://example.co.app
  2. 登台服务器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

  1. A production server https://example.co.app
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文