【Docker】Swagger環境を構築する
【Docker】Swagger環境を構築する
Docker で Swagger環境を構築するメモ
docker-compose.yml 作成
version: '3.0'
services:
swagger-editor:
image: swaggerapi/swagger-editor
container_name: "swagger-editor"
ports:
- "8001:8080"
swagger-ui:
image: swaggerapi/swagger-ui
container_name: "swagger-ui"
ports:
- "8002:8080"
volumes:
- ./api/openapi.yaml:/openapi.yaml # Swagger File
environment:
SWAGGER_JSON: /openapi.yaml # Swagger File
swagger-api:
image: stoplight/prism:latest
container_name: "swagger-api"
ports:
- "8003:4010"
command: mock -h 0.0.0.0 /openapi.yaml # Swagger File
volumes:
- ./api/openapi.yaml:/openapi.yaml # Swagger File
Sample yaml作成
openapi: "3.0.3"
info:
title: "Test1-API"
version: "1.0.0"
paths:
"/helloWorld":
get:
responses:
"200":
description: "test-ok"
content:
application/json:
schema:
type: string
example: "Hello World"
起動
Dockerを起動します。
docker-compose up -d
起動したら以下のURLで確認。
| Swagger | URL |
|---|---|
| Swagger Editor | http://localhost:8001/ |
| Swagger UI | http://localhost:8002/ |
| Swagger API mock | http://localhost:8003/ |
これでSwaggerの環境を作成できました。