DEV Community

Swagger UI + Docker: Initial Setup

The environment consists of a Mac with an Apple M1 CPU running Sonoma 14.6.1 OS and Docker Desktop version 4.34.2. The directory structure has three subdirectories: top, docker, and openapi. The docker subdirectory contains a .env file and a docker-compose.yml file, while the openapi subdirectory contains an openapi.yml file. The .env file sets the SWAGGER_UI_HOST_PORT variable. The docker-compose.yml file defines a service called swagger-ui, which uses the official swaggerapi/swagger-ui:v5.17.14 image. The environment variable SWAGGER_JSON is set to the absolute path of the openapi.yml file, which is mounted as a volume inside the Docker container. The container exposes port 8080, and the openapi.yml file defines a minimal API documentation conforming to OAS 3.0.3. To create the container and image, the user needs to execute docker compose create in the terminal, then start the container with docker compose start. Finally, the user can access Swagger UI by opening http://localhost:{SWAGGER_UI_HOST_PORT} in their browser.
favicon
dev.to
dev.to
Create attached notes ...