question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

urls option from custom swagger-config.yaml ignored.

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
pavelsrcommented, Sep 9, 2021

Just tested, seems like documentation is really outdated. swagger-config.yaml is not supported for now, only swagger-config.json

Also having /usr/share/nginx/html/swagger-config.json is not enough, need to set -e CONFIG_URL=/swagger-config.json additionally while docker run.

$ docker images --digests --filter "reference=swaggerapi/swagger-ui"
REPOSITORY              TAG       DIGEST                                                                    IMAGE ID       CREATED       SIZE
swaggerapi/swagger-ui   latest    sha256:8d3f30b936cf117f83c87379aadc7b7507735a3e899b1d8fcc38f8d0939eee77   ecb990ee92e8   4 weeks ago   101MB
3reactions
pschichtelcommented, Jan 28, 2021

Ha… apparently the switch to JSON was all that is needed… So maybe some documentation is needed here, that Yaml is not supported for the config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger UI configuration with swagger-config.yaml
From the document, it seems we don't need to config anything in index.html if use swagger-config.xml, actually, it doesn't work from my side ......
Read more >
Configuration - Swagger Documentation
The swagger-config.yaml in the project root directory, if it exists, is baked into the application ... Will be ignored if urls or spec...
Read more >
Using OpenAPI and Swagger UI - Quarkus
An OpenAPI document that conforms to the OpenAPI Specification is itself a valid JSON object, that can be represented in yaml or json...
Read more >
F.A.Q - Springdoc-openapi
Then configure, the path of your custom UI yaml file. springdoc.swagger-ui.url=/api-docs.yaml. Is there a way to ...
Read more >
Top 5 swagger-ui-express Code Examples - Snyk
setHeader('Content-Type', 'application/json') res.send(swaggerSpec) }), app.use(swaggerConfig.routerPath, swaggerUi.serve, swaggerUi.setup(swaggerSpec)) }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found