DEV Community

Cover image for Try using swagger-ui
lightkun
lightkun

Posted on • Updated on

 

Try using swagger-ui

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

github

https://github.com/katsuya-n/docker-swagger-ui

environment

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'
services:
  swagger-ui:
    image: swaggerapi/swagger-ui
    container_name: swagger-ui
    ports:
      - "8001:8080"
    volumes:
      - ./swagger:/usr/share/nginx/html/swagger
    environment:
      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)

The AI Brief

AI generated git commit messages

Minimize the struggle of remembering what you just coded. AI-generated commits make it easier to manage projects and keep track of changes. The Nutlope/aicommits project demonstrates how AI can improve commit messages.

I open sourced an AI that creates any UI in seconds

Make AI-generated user interfaces a breeze. This open-source project harnesses the power of generative AI technologies like chatGPT to create versatile, quick, and intuitive UI components.

Use AI to commit like a PRO in 1 second

Upgrade your commit message game with AI. Boost your productivity by using ChatGPT to generate commit messages and avoid context switching. OpenCommit is an open-source library that helps you achieve this easily.

Build your own ChatGPT starter kit

Train AI models on custom data for improved domain-specific knowledge. Combine the power of WebView technologies and this starter kit to train your ChatGPT model on specific websites, allowing for better-optimized outcomes.