Javascript 带有Swagger-config.yaml的Swagger用户界面配置

Javascript 带有Swagger-config.yaml的Swagger用户界面配置,javascript,swagger,swagger-ui,swagger-2.0,openapi,Javascript,Swagger,Swagger Ui,Swagger 2.0,Openapi,根据斯威格文件 Swagger UI在四个位置接受配置参数 从最低优先级到最高优先级: 项目根目录中的swagger-config.yaml(如果存在)将烘焙到应用程序中 作为参数传递给Swagger UI的配置对象(Swagger UI({…})) 从指定的configUrl获取的配置文档 在URL查询字符串中作为键/值对传递的配置项 我曾尝试将swagger-config.yaml放在应用程序的根目录中,但它不起作用 我遵循了swagger安装步骤,其工作正常。 但swagger自定义配置的

根据斯威格文件

Swagger UI在四个位置接受配置参数

从最低优先级到最高优先级:

  • 项目根目录中的swagger-config.yaml(如果存在)将烘焙到应用程序中
  • 作为参数传递给Swagger UI的配置对象(Swagger UI({…}))
  • 从指定的configUrl获取的配置文档
  • 在URL查询字符串中作为键/值对传递的配置项
  • 我曾尝试将swagger-config.yaml放在应用程序的根目录中,但它不起作用

    我遵循了swagger安装步骤,其工作正常。 但swagger自定义配置的步骤不起作用。我保存了以下文件:

     swagger-ui
       |--swagger-config.yaml
       |--index.html
    
    swagger-config.yaml index.html
    知道我是否遗漏了什么吗?

    我也有这个问题。从文档中可以看出,如果使用swagger-config.xml,我们似乎不需要在index.html中配置任何内容,实际上,从我的角度来看,它不起作用,我还没有找到原因。 但如果改用configUrl,它会工作

    // Begin Swagger UI call region
    const ui = SwaggerUIBundle({
      //url: "https://petstore.swagger.io/v2/swagger.json",
      //dom_id: '#swagger-ui',
      configUrl: "../swagger-config.yaml",
      deepLinking: true,
      presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIStandalonePreset
      ],
      plugins: [
        SwaggerUIBundle.plugins.DownloadUrl
      ],
      layout: "StandaloneLayout"
    })
    
    并且可以将其配置为支持阵列

    ---
    urls:
     - url: "https://petstore.swagger.io/v2/swagger.json"
       name: "url1"
       
     - url: "https://petstore.swagger.io/v2/swagger.json"
       name: "url2"
    

    如何运行Swagger UI-从文件系统或web服务器打开页面,或使用
    npm start
    ?我在JBoss和文件系统上都试过了。你说它不起作用。你能详细说明一下吗?当您查看web浏览器的控制台时,是否看到任何错误消息?当您查看浏览器的网络控制台时,是否看到任何成功的下载尝试?@MahendraKapadne您是否解决了问题?我遇到了完全相同的问题-swagger ui没有获取我放入swagger ui根目录中的swagger-config.yaml。@Bernd目前,我在url中硬编码了相对URI。
    // Begin Swagger UI call region
    const ui = SwaggerUIBundle({
      //url: "https://petstore.swagger.io/v2/swagger.json",
      //dom_id: '#swagger-ui',
      configUrl: "../swagger-config.yaml",
      deepLinking: true,
      presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIStandalonePreset
      ],
      plugins: [
        SwaggerUIBundle.plugins.DownloadUrl
      ],
      layout: "StandaloneLayout"
    })
    
    ---
    urls:
     - url: "https://petstore.swagger.io/v2/swagger.json"
       name: "url1"
       
     - url: "https://petstore.swagger.io/v2/swagger.json"
       name: "url2"