DEV Community 👩‍💻👨‍💻

Cover image for Try using swagger-ui

Posted on • Updated on

Try using swagger-ui

Hi all,
I try using swagger-ui on docker. It is too easy to build.



docker image : swaggerapi/swagger-ui

directory structure

├── docker-compose.yml
└── swagger
                  └── api.yaml
Enter fullscreen mode Exit fullscreen mode

1. make docker-compose.yml

version: '3.3'
    image: swaggerapi/swagger-ui
    container_name: swagger-ui
      - "8001:8080"
      - ./swagger:/usr/share/nginx/html/swagger
      API_URL: swagger/api.yaml
Enter fullscreen mode Exit fullscreen mode

If you use port number 8001, you should change other.
Acocording to my research, docker swagger-ui image seems to use nginx. So, file path is /usr/share/nginx/html/swagger.

2. make swagger directory and api.yaml

If you just want to build swagger-ui, I recommend copy swagger editor sample and paste in api.yaml.

3. build

Run docker command.
docker-compose up -d

You check http://localhost:8001/ when docker build is completed.

Alt Text

how to edit api.yaml?

By the way, do you think it is not easy to edit yaml file?
If you use Visual Studio Code, you can use Swagger Viewer. It can see preview of editing file in real time and is comfortable.

Alt Text

Top comments (0)

Tired of sifting through your feed?

You can change your feed and see more relevant posts by adding a rating to different tags on DEV. Head here to adjust your weights.