Swagger-ui: `urls` config ignored when set in a config file provided through configURL

Created on 19 Apr 2018  路  4Comments  路  Source: swagger-api/swagger-ui

| Q | A
| ------------------------------- | -------
| Bug or feature request? | Bug
| Which Swagger/OpenAPI version? | NA
| Which Swagger-UI version? | 3.13.4
| How did you install Swagger-UI? | npm
| Which browser & version? | Firefox 59.0.2
| Which operating system? |

Demonstration API definition

Test using the petstore API聽def

Configuration (browser query string, constructor, config.yaml)

See below

Expected Behavior

When trying to configure the urls params provided in a configURL, it is ignored.
The following message is displayed: "No API definition provided."

Index HTML:

const ui = SwaggerUIBundle({
    configUrl: "./swagger-config.json"
});

JSON Configuration:

{
        dom_id: "#swagger-ui",
        deepLinking: true,
        presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
        plugins: [SwaggerUIBundle.plugins.DownloadUrl],
        layout: "StandaloneLayout",
        urls: [
            {
                name: "test",
                url: "http://petstore.swagger.io/v2/swagger.json"
            }
        ]
    }

When I use the same configuration directly in the HTML, the urls is well considered.

configuration bug

Most helpful comment

I don't know if anybody needs this, but I have got it to work. I am not sure if this is the intended way swagger wants to do or if this is a workaround, but here goes -

I have got most of the configuration in the index.html -

const ui = SwaggerUIBundle({
        configUrl : "./swagger-config.json",
        dom_id: '#swagger-ui',
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout"
      })

The only thing I am picking from the configUrl is the urls themselves. This is the swagger-config.json -

urls: [
    {
      "url": "http://petstore.swagger.io/v2/swagger.json",
      "name": "Petstore"
    },
    {
      "url": "http://localhost:9002/api-docs/swagger-test",
      "name": "Petstore2"
    },
    {
      "url": "http://localhost:9002/api-docs/swagger-test",
      "name": "Petstore3"
    }
  ]

All 4 comments

This likely shares a root cause with https://github.com/swagger-api/swagger-ui/issues/4267

Is there any update / resolution of this issue?
Has anyone figured out a workaround for this ?

I don't know if anybody needs this, but I have got it to work. I am not sure if this is the intended way swagger wants to do or if this is a workaround, but here goes -

I have got most of the configuration in the index.html -

const ui = SwaggerUIBundle({
        configUrl : "./swagger-config.json",
        dom_id: '#swagger-ui',
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout"
      })

The only thing I am picking from the configUrl is the urls themselves. This is the swagger-config.json -

urls: [
    {
      "url": "http://petstore.swagger.io/v2/swagger.json",
      "name": "Petstore"
    },
    {
      "url": "http://localhost:9002/api-docs/swagger-test",
      "name": "Petstore2"
    },
    {
      "url": "http://localhost:9002/api-docs/swagger-test",
      "name": "Petstore3"
    }
  ]

I have the same issue. Do you have any solution? I'm using a non-bundle version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newtechfellas picture newtechfellas  路  47Comments

dalbani picture dalbani  路  42Comments

peter004 picture peter004  路  49Comments

azamatsulaiman picture azamatsulaiman  路  34Comments

marlandy picture marlandy  路  53Comments