DEV Community

box
box

Posted on

1

Swagger UI + Docker: Initial Setup

Environment

  • Mac

    • CPU: Apple M1
    • OS: Sonoma 14.6.1
  • Docker Desktop

Dir Structure

dir-structure

* Drawn by mermaid.

graph TD;
    subgraph top["top"]
        subgraph docker["docker"]
            env[".env"]
            docker_compose["docker-compose.yml"]
        end
        subgraph openapi["openapi"]
            openapi_file["openapi.yml"]
        end
    end
Enter fullscreen mode Exit fullscreen mode

docker/.env

SWAGGER_UI_HOST_PORT={host-port}
Enter fullscreen mode Exit fullscreen mode

docker/docker-compose.yml

services:
  swagger-ui:
    image: swaggerapi/swagger-ui:v5.17.14
    environment:
      SWAGGER_JSON: /oas/openapi.yml
    ports:
      - "${SWAGGER_UI_HOST_PORT}:8080"
    volumes:
      - ../openapi:/oas
Enter fullscreen mode Exit fullscreen mode

openapi/openapi.yml

Define a minimal API documentation conforming to OAS 3.0.3.

openapi: 3.0.3
info:
  title: Sample API
  version: 1.0.0
paths:
  /hello:
    get:
      summary: Hello World Request
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string
                example: "Hello, World!"
Enter fullscreen mode Exit fullscreen mode

Docker

Create Container and Image.

  1. Open the terminal.

  2. Move the current-dir to the location where docker-compose.yml is located.

  3. Execute docker compose create.

    docker compose create
    

Open Swagger UI.

  1. Start the container.

    docker compose start
    
  2. Open http://localhost:{SWAGGER_UI_HOST_PORT}.

  3. Stop the container once satisfied.

    docker compose stop
    

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more