Logo

dev-resources.site

for different kinds of informations.

Swagger UI + Docker: Initial Setup

Published at
10/14/2024
Categories
swagger
openapi
docker
Author
box_protection
Categories
3 categories in total
swagger
open
openapi
open
docker
open
Author
14 person written this
box_protection
open
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
    
swagger Article's
30 articles in total
Favicon
Crudify: Automate Your Mongoose CRUD Operations in NestJS
Favicon
🚀 API Maker : Release Notes for v1.9.0
Favicon
What Does Swagger x-nullable Mean?
Favicon
Two Reasons on Why We Ship LiveAPI with An ROI Calculator
Favicon
.NET 9 Revolutionizing documentation of APIs : From Swashbuckle to Scalar 🚀
Favicon
What is the Best Way to Group REST API methods in Swagger UI
Favicon
How Scale Changes Everything - The LiveAPI Perspective
Favicon
What is SwaggerHub?
Favicon
Ever wished to maintain API Docs with ease? Introducing LiveAPI: Super Convenient API Docs
Favicon
Integrate Swagger UI with Codeigniter4
Favicon
How to Use Swagger UI Locally: A Step-by-Step Guide
Favicon
Musings Over What Makes LiveAPI Different (from Swagger Et Cetera)
Favicon
Missing Required Key in Body of PUT /odata/Assets({Key}) Edit an asset on UiPath.WebApi 18.0
Favicon
An Online Free API AutoTesting Tool That Completes 160 Hours of Testing Work for 20 APIs in Just 3 Minutes
Favicon
How to Improve Development Efficiency Through Automated API Testing
Favicon
Top 8 Swagger Codegen Alternatives
Favicon
JavaFX In Action #8 with Ulas Ergin: How JavaFX helps to migrate from Swing to React UIs, all combined in one Java app
Favicon
Exploring AutoAPI: An Automation Tool to Simplify Frontend Development
Favicon
Django Rest framework with Swagger
Favicon
Seamlessly Integrate Swagger with JWT Authentication in NestJS
Favicon
New Swagger-UI embedding Cloud TypeScript Editor with RPC SDK
Favicon
Laravel API Documentation Made Easy: Step-by-Step Swagger Integration
Favicon
Introducing Swama: A CLI Tool for Swagger/OpenAPI Interactions
Favicon
StudySpy: Building the new PublicApi v2
Favicon
Swagger UI + Docker: Initial Setup
Favicon
apigen-ts – Simple TypeScript API Client Generator
Favicon
Automating Swagger Documentation with Joi in Node.js: Simplify Your API Documentation Workflow
Favicon
Merge and bundle open api yaml files for swagger
Favicon
Gerando Documentação de API Automática com Fastify, @fastify/swagger e Zod
Favicon
Hosting Swagger-UI using GitHub Pages

Featured ones: