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.48k stars 8.96k forks source link

Not able to run multiple YAML files on swagger-ui #5496

Open a-ajay opened 5 years ago

a-ajay commented 5 years ago

Q&A (please complete the following information)

Content & configuration

I use the below command to run docker locally on my machine:

docker run -d -p 80:8080 -e SWAGGER_JSON=/foo/v210.yaml -v /home/mydir:/foo swaggerapi/swagger-ui

v210.yaml is the YAML file, I have 2 more of them. Now,

  1. I want a drop-down, to select the required version or
  2. I can combine all the spec of YAML files into one YAML file, and then a drop-down to select the required spec

Please let me know the docker command to do this.

webron commented 5 years ago

Have you checked the documentation on running it as a docker image? https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md#docker

That also has a link as to how to configure Swagger UI inside the docker image, including running it with multiple files.

a-ajay commented 5 years ago

Thanks, @webron - I found the link very useful. Now I have one more issue, Below is the command, I'm using it to run multiple files on swagger

docker run -d -p 80:8080 -e URLS="[{name:\"v20\", url:\"/foo/v20.yaml\"}, {name:\"v21\", url:\"/foo/v21.yaml\"},{name:\"v22\", url:\"/foo/v22.yaml\"}]" -v /home:/foo swaggerapi/swagger-ui

But the YAML files are in local machine, how do I provide its URL?

yanxinyuan commented 4 years ago

Current now, I use this way to work around.

Dockerfile:

FROM swaggerapi/swagger-ui
COPY ./*.yml /usr/share/nginx/html/
ENV URLS "[{url:\"/Sample1.yml\",name:\"Sample1\"},{url:\"/Sample2.yml\",name:\"Sample2\"}]"
step1: docker build -t apis:v1 .
step2: docker run -p 82:8080 apis:v1
step3: http://<ip>:82
waterkip commented 4 years ago

This issue can be closed I think, it is fixed with #5565

jimmy-wei commented 3 years ago

An other workaround solution:

docker run -d -p 80:8080 -e URLS='[{url: "v20.yaml", name: "v20"},{url: "v21.yaml", name: "v21"}]' -v /home/v20.yaml:/usr/share/nginx/html/v20.yaml -v /home/v21.yaml:/usr/share/nginx/html/v21.yaml swaggerapi/swagger-ui