swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.67k stars 8.97k forks source link

When using both CONFIG_URL and API_URLS, the API_URLS are ignored. #4942

Open CameronGo opened 6 years ago

CameronGo commented 6 years ago

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition: I tested this with the petstore OpenAPI doc also.

Swagger-UI configuration options: This is what my config.json looks like

{
    "dom_id": "#swagger-ui",
    "deepLinking": true,
    "docExpansion": "none"
}

Describe the bug you're encountering

When I launch swagger UI with the API_URLS environment set, I get the expected behavior with 2 API docs returned. When I launch swagger UI with the CONFIG_URL environment set, I get the expected behavior with regards to the doc expansion, etc. If I have both API_URLS and CONFIG_URL set, then the CONFIG is used, but no API doc is loaded.

To reproduce...

You can use this docker-compose file to launch the service with the same options I'm using:

version: '3'

services:
  swagger-ui:
    image: swaggerapi/swagger-ui
    ports:
      - "8080:8080"
    environment:
      - CONFIG_URL=https://hostname/path/config.json
      - API_URLS=[{"name":"v2","url":"https://petstore.swagger.io/v2/swagger.json"},{"name":"v3","url":"https://petstore.swagger.io/v2/swagger.json"}]

Steps to reproduce the behavior: Once Swagger UI is launched you will see a blank page is loaded. You can manually explore an API doc by putting in the URL and it will use the settings from the config.json file as defined.

You can alternate back and forth removing one or the other and see that the settings are working independently, just not together.

Expected behavior

I would expect it to use both the settings from the config file found from the CONFIG_URL and also to load the API docs from the API_URLS.

shockey commented 6 years ago

@CameronGo, what does your config.json look like?

CameronGo commented 6 years ago

@shockey - the config.json contents were actually in the inital bug report, but here it is:

{
    "dom_id": "#swagger-ui",
    "deepLinking": true,
    "docExpansion": "none"
}