如何在swagger ui中显示当前url?

如何在swagger ui中显示当前url?,url,swagger,display,hostname,absolute-path,Url,Swagger,Display,Hostname,Absolute Path,我想显示当前的url,例如:https://{hostname}/{pathname}…,在这里我运行的是swagger ui,而不是硬编码的相对路径。是否有任何可能的解决方案至少可以获取当前主机名 我尝试过几种方法,但似乎swagger中的文本只能硬编码。我自己也有这种需要,以下是我的代码: const ui = SwaggerUIBundle({ url: window.location.protocol + '//' + window.location.host + '/api/s

我想显示当前的url,例如:https://{hostname}/{pathname}…,在这里我运行的是swagger ui,而不是硬编码的相对路径。是否有任何可能的解决方案至少可以获取当前主机名


我尝试过几种方法,但似乎swagger中的文本只能硬编码。

我自己也有这种需要,以下是我的代码:

const ui = SwaggerUIBundle({
    url: window.location.protocol + '//' + window.location.host + '/api/swagger.json',
    dom_id: '#swagger-ui',
    deepLinking: true,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    oauth2RedirectUrl: window.location.protocol + '//' + window.location.host + '/swagger-ui/oauth2-redirect.html',
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl,
      HideTopbarPlugin
    ],
    layout: "StandaloneLayout"
  });

请确保URL中指向swagger.json的路径正确。

您能给我们展示一下您的意思吗?Hy Helen,谢谢您的提示。刚刚添加了一个截图。您的截图显示了绝对URL。您要更改为绝对URL的相对URL在哪里?不幸的是,我无法显示我的应用程序,因为它包含一些机密信息。在我的应用程序中,我只有相对URL,例如../somepath/example.json,我想将其更改为绝对路径,例如,在本例中,头下方的路径是指具有绝对路径的json文件。然而,在我的例子中,它只显示了相对路径。