Skip to content

Swagger-UI 3.x not loading 3.x Themes #28

@ghost

Description

Preface: Apologies if this is a noobish question, Frontend development is not my domain of expertise. :(

I cannot get Swagger-UI 3.x to load any 3.x swagger-ui-theme CSS. Rather, the default CSS theme is always being loaded. Using my browser's debug tools I can see the JS console is error free, and the theme-xxx.css I specify (using your instructions) is in fact being served to the browser.

Below is a Dockerfile and a couple BASH commands to replicate the issue quickly (all work on Linux or Windows + Cygwin + Docker Toolbox).

  1. Write the below lines into a file named Dockerfile:
FROM swaggerapi/swagger-ui:v3.0.2
# mount an index file with the `<link rel="stylesheet" href="path/to/theme.css" />` one-liner
COPY ./index-feeling-blue.html /usr/share/nginx/html/index.html
COPY ./theme-feeling-blue.css /usr/share/nginx/html/css/theme-feeling-blue.css
EXPOSE 8080
  1. Use your favorite means to obtain your preferred 3.x theme CSS from this repo (in my case feeling-blue).

  2. Obtain the swagger-ui index.html via this link (you may need to fix the paths to the swagger-ui js components) or from the docker image referenced in the first line:

docker pull swaggerapi/swagger-ui:v3.0.2
# use docker run to start a container using the swagger-ui image, and obtain its container id
$ docker run -d swaggerapi/swagger-ui:v3.0.2
<container_id>

# shell into the docker
$ docker exec -it <container_id> /bin/sh
/ # cat /usr/share/nginx/html/index.html
  1. Put the theme CSS, Dockerfile, and custom index.html into a common directory, change into it, then run:
docker build -t <your_registry>/<your_image>:<your_tag> .
docker run -d -p 8080:8080 <your_registry>/<your_image>:<your_tag>
  1. Goto http://localhost;8080 and observe that your desired theme is NOT loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions