I am following the instructions to set up a docker container with a local API docs file, with an api.yaml file in the local repo in the folder $HOME/my-app, and launching the container as follows:
docker run -p 80:8080 -e SWAGGER_JSON=/docs/api.yaml -v $HOME/my-app:/docs swaggerapi/swagger-ui
However, it returns in a 404 ("GET /docs/api.yaml HTTP/1.1" 404 126).
It's not clear what I'm doing wrong and any help would be appreciated.
Thanks for reading.
I used this and it works :
version: "3.3"
services:
swagger-ui:
image: swaggerapi/swagger-ui
container_name: "swagger-ui"
ports:
- "80:8080"
volumes:
- ./docs/api.yaml:/api.yaml
environment:
SWAGGER_JSON: /api.yaml
To be honest, the doc is unclear about SWAGGER_JSON environment variable.
thanks @AirDur here is docker run command
docker run -p 80:8080 -e SWAGGER_JSON=/api.yaml -v /
/api.yaml:/api.yaml swaggerapi/swagger-ui
This page (installation.md) memtioned the SWAGGER_JSON but not in this page (configuration.md), really confusing.
Using the above still results in showing the default Swagger Petstore example :(
If setting
volumes:
- ./docs/api.yaml:/api.yaml
environment:
SWAGGER_JSON: /api.yaml
what URL will the file be served on? I assumed just localhost, which that doesn't work, but localhost/api.yaml doesn't work either.
I tried @AirDur solution and it works, thanks!
@mandreyel I can see the file under localhost/api.yaml. Be sure that the path ./docs/api.yaml exists, it's relative to the docker-compose.yaml file location.
Problem is the swagger UI always shows up with the Petstore URL in the text box. Is there a way to change it? It's annoying to change it manually every time.
@mandreyel I had this same problem and was using the "tag latest" just like you, so I decided to test the most stable version, the v3.24.3 and the problem was solved
Most helpful comment
I used this and it works :
To be honest, the doc is unclear about SWAGGER_JSON environment variable.