Reference:
- OpenApi Guide About Swagger Specification | Documentation | Swagger
- swagger editor documentation: Swagger Documentation
Method 1: Use swagger-editor
Setup from Docker
The Swagger Editor can be found in this public repository on Docker.
Please run the following to run the Editor in your local machine from Docker.
|
Open the editor in the browser with: http://machine-name
Write yaml
Method 1: According to the OpenApi Guide. write on the left, display on the right of the window.
Method 2: use the funtion swagger editor supplied to insert some part.
Method 2: Use Vscode plugin
insall the plguin swagger viewer in vscode.
write the yaml according to the OpenApi Guide.
display the swagger page use: shift + alt + p
swagger-ui
https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md
Docker
You can pull a pre-built docker image of the swagger-ui directly from Docker Hub:
docker pull swaggerapi/swagger-ui
docker run -p 80:8080 swaggerapi/swagger-ui
Will start nginx with Swagger UI on port 80.
Or you can provide your own swagger.json on your host
|
The base URL of the web application can be changed by specifying the BASE_URL
environment variable:
docker run -p 80:8080 -e BASE_URL=/swagger -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
This will serve Swagger UI at /swagger
instead of /
.
Reference:
Swagger UI on docker for testing REST APIs : https://medium.com/wesionary-team/swagger-ui-on-docker-for-testing-rest-apis-5b3d5fcdee7