swagger-api / swagger-api/swagger-ui

urls option from custom swagger-config.yaml ignored.

Open
#6,019 17 comments 5 reactions 2 assignees View on GitHub

@tim-lai is already working on this.

Since May 18, 2020.

cat: docker Hacktoberfest type: bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Archlinux
  • Browser: Firefox
  • Version: 76
  • Method of installation: Docker
  • Swagger-UI version: 3.25.3
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger-UI configuration options:
I tried both yaml and json:

---
urls:
  - name: Master API
    url: specs/master.yaml
  - name: Bot API
    url: specs/bot.yaml
{
    "urls": [
        {
            "name": "Master API",
            "url": "specs/master.yaml"
        },
        {
            "name": "Bot API",
            "url": "specs/bot.yaml"
        }
    ]
}

I looked at the swagger-config.yaml from this repository for reference.

Describe the bug you're encountering

I have a micro service system with various swagger-specified APIs. My goal was to create a dedicated application, that integrates all the swagger documentation. ron in IRC suggested to use the urls option to configure multuple spec URLs to be selected. So I pulled the swaggerapi/swagger-ui:v3.25.3 image, copied my files in specified the URLS environment variable. As expected: The swagger UI shows the first URL in the list by default and allows to switch between the URLs using a selection in the header. Because we have many APIs, I then tried to use a custom swagger-config.yaml by copying it into the container and specifying CONFIG_URL=swagger-config.yaml with the contents from above.

The UI seems to load the correct swagger-config.yaml (or .json) file, but it still shows the default petstore spec, apparently ignoring the provided urls option.

To reproduce...

Steps to reproduce the behavior:

  1. Copy a swagger spec to /usr/share/nginx/html/specs/ inside the swaggerapi/swagger-ui:v3.25.3 image
  2. Copy a swagger-config.yaml to /usr/share/nginx/html/swagger-config.yaml with the following content:
    ---
    urls:
      - name: Spec
        url: specs/<spec file name>
    
  3. Add ENV CONFIG_URL=swagger-config.yaml to the Dockerfile (or set it while running the container)
  4. Open the swagger UI in the browser
Expected behavior

I'd expect to see the spec from the configured URL

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.