如何用swagger editor编写swagger.yaml

Reference:

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.

docker pull swaggerapi/swagger-editor

docker run -p 80:8080 swaggerapi/swagger-editor

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

docker run -d -p 80:8080 -e SWAGGER_JSON=/usr/share/nginx/html/doc/swagger.yaml -v /xxxx/docs:/usr/share/nginx/html/doc swaggerapi/swagger-ui

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值