How to launch Swagger UI and Swagger Editor in Docker

What is Swagger

Swagger is an API construction framework that can make API document design and API mock (prototype) requests. The Swagger tools used this time are the following three.

tool Explanation
Swagger Spec (Spec = Specification = Specification) This is a document related to Swagger specifications, and is YAML./Written in JSON format.
Swagger Editor A tool that allows you to edit Swagger Spec files that run on your browser and check the syntax in real time.
Swagger UI A tool that dynamically generates documents from Swagger Spec.

For other Swagger related tools, please check the link on the official page.

About the relationship of Swagger tools

First, I tried to illustrate how the Swagger Editor and Swagger UI are used, with the Swagger Spec file generation as the main axis. As an image used this time, use Swagger Editor to edit and define SwaggerSpec which is the API specification on the browser, and if you can confirm the syntax, enter it in the actual yaml file so that you can refer to it from Swagger UI. It is a flow.

スクリーンショット 2020-10-24 17.24.54.png

procedure

Setting point:

  1. Set docker-compose.yml to create Swagger Editor and Swagger UI images.
  2. Put the Swagger definition as sample.yaml.

docker-compose.yml


version: '3.7'
services:
 swagger-editor:
    image: swaggerapi/swagger-editor
    ports:
      - "8001:8080"

  swagger-ui:
    image: swaggerapi/swagger-ui
    ports:
      - "8002:8080"
    volumes:
      - ./sample.yaml:/sample.yaml
    environment:
      SWAGGER_JSON: sample.yaml

Directory structure



├── docker-compose.yaml
└── sample.yaml

Do the following in your terminal:

Terminal


$ docker-compose up

Swagger Editor starts at https: // localhosst: 8001, and Swagger UI starts at https: // localhost: 8002.

Recommended Posts

How to launch Swagger UI and Swagger Editor in Docker
How to use Docker in VSCode DevContainer
Understand in 5 minutes !! How to use Docker
Note: [Docker] How to start and stop
How to call libraries such as JQuery and JQuery UI in Liferay 7 / DXP
How to check the logs in the Docker container
How to update pre-built files in docker container
How to install Docker
How to launch another command in a Ruby program
How to delete untagged images in bulk with Docker
How to convert A to a and a to A using AND and OR in Java
How to handle TSV files and CSV files in Ruby
How to set Docker nginx
How to separate words in names in classes, methods, and variables
[Forge] How to register your own Entity and Entity Render in 1.13.2
[Rails] How to define macros in Rspec and standardize processing
How to set character code and line feed code in Eclipse
What happened in "Java 8 to Java 11" and how to build an environment
How to call and use API in Java (Spring Boot)
Display API definition in Swagger UI using Docker + Rails6 + apipie
Differences in how to handle strings between Java and Perl
How to install PHP 7.4 and SQL Server drivers in CentOS 7.7
[Docker context] ~ How to access docker in remote environment from VScode ~
How to change BackgroundColor etc. of NavigationBar in Swift UI
[Xcode] How to arrange Xcode and Simulator screens in full screen
How to include PKCE Code_Verifier and Code_Challenge in JMeter requests
How to create and launch a Dockerfile for Payara Micro
How to dynamically switch between FIN and RST in Netty
Write DiscordBot to Spreadsheets Write in Ruby and run with Docker
How to use Lombok in Spring
How to use StringBurrer and Arrays.toString.
How to find May'n in XPath
How to hide scrollbars in WebView
How to use EventBus3 and ThreadMode
How to iterate infinitely in Ruby
How to run Ant in Gradle
How to master programming in 3 months
How to POST JSON in Java-Method using OkHttp3 and method using HttpUrlConnection-
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
How to run JavaFX on Docker
How to learn JAVA in 7 days
How to call classes and methods
How to use equality and equality (how to use equals)
How to install Bootstrap in Ruby
How to set and use profile in annotation-based Configuration in Spring framework
How to connect Heroku and Sequel
How to use InjectorHolder in OpenAM
[jOOQ] How to CASE WHEN in the WHERE / AND / OR clause
How to run a job with docker login in AWS batch
How to delete large amounts of data in Rails and concerns
How to introduce jQuery in Rails 6
How to use classes in Java?
How to name variables in Java
How to get and add data from Firebase Firestore in Ruby
How to set Lombok in Eclipse
How to implement UI automated test using image comparison in Selenium
Challenge to install WSL2 and docker
How to encrypt and decrypt with RSA public key in Java
How to build CloudStack using Docker
How to start Camunda with Docker
How to concatenate strings in java