YApi visual interface management platform

This topic describes YApi

  1. Open source by YMFE, Yapi is designed to provide more elegant interface management services for developers, products, and testers. It can help developers easily create, publish, and maintain apis. Qunar Mobile Architecture Group (YMFE) is the most imaginative, creative and influential front-end team of qunar, which is composed of FE, iOS and Android engineers.
  2. Permission management YApi mature team management flat project permission configuration to meet the needs of various enterprises
  3. Visual interface management Based on WebSocket multi-person collaboration interface editing function and like Postman testing tool, so that multi-person collaboration to enhance development efficiency
  4. Mock Server Easy to use Mock Server, no longer worry about Mock data generation
  5. Automatic test Perfect interface automatic test to ensure the correctness of data
  6. Data import support to import Swagger, Postman, HAR data format, easy to migrate old projects
  7. Plug-in mechanism Powerful plug-in mechanism to meet various service requirements
  8. Yapi yapi.ymfe.org/documents/i official document…

Docker environment builds YApi

Of course, if you have Docker installed on your server

Example Create a MongoDB data volume

Go to docker volume create mongo_data_yapiCopy the code

Start the mongo

Mongo_data_yapi docker run -d --name mongo-yapi -v mongo_data_yapi/data/If you do not have mongodb in your docker, this command will automatically download mongodb for youCopy the code

Obtain YApi image, version information can be viewed in ali Cloud image warehouse

Perform docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapiCopy the code

Initialize the YApi database index and administrator account (remember that the following command needs to be typed line by line \ as newline character)

Run docker runit --rm --link mongo-yapi:mongo --entrypoint NPM --workdir/API /vendors \ Registry.cn-hangzhou.aliyuncs.com/anoy/yapi \ run install - will be displayed after the server has been completed the administrator account and password Please record downCopy the code

The custom configuration file is mounted to the directory/API /config.json

The official custom profile address (https://github.com/YMFE/yapi/blob/master/config_example.json?spm=5176.1972344.1.6.LYdCBe&file=config_example .json )Copy the code
Enter docker(docker installed after the default storage directory is /var/lib/docker) directory CD /var/lib/docker create API directory mkdir API Go to the API directory and create a config.json file touch config.json Copy the contents of the official documents to this file for savingCopy the code
The official config. Json {"port": "3000"."adminAccount": "[email protected]"."db": {
"servername": "127.0.0.1"."DATABASE": "yapi"."port": 27017,
"user": "test1"."pass": "test1"."authSource": ""
},
"mail": {
"enable": true."host": "smtp.163.com"."port": 465,
"from": "***@163.com"."auth": {
"user": "***@163.com"."pass": "* * * * *"}}}Copy the code

Start YApi (remember that the following commands need to be typed line by line \ is a newline character)

docker run -d \
--name yapi \
--link mongo-yapi:mongo \
--workdir /api/vendors \
-p 3000:3000\ -- Port is3000
registry.cn-hangzhou.aliyuncs.com/anoy/yapi \
server/app.js
Copy the code

curl 127.0. 01.:3000Run the command to check whether the following value is displayed. If yes, the installation is successfulCopy the code

Visit YApi

External host access domain name :3000 or IP address :3000 Login account [email protected] Password ymfe.org(the user name and password used to initialize YApi)

Internal curl is accessible, but external host browsers are not

  1. There are restrictions on external access to internal servers of Ali Cloud. I started YApi with 3000 port, so if external users want to access the service, I must open the 3000 port of my server in the inbound direction of ali Cloud console, so that external users can access the service.
  • How to open port to enter ali Cloud server instance list, click more, select security group configuration


    Click Configure Rules, select the inbound direction, and add security group rules

    Follow the configuration as shown in the figure

  1. The server cannot be accessed because the firewall is not disabled

YApi related operations

Close the Yapi

docker stop yapi
Copy the code

Start the Yapi

docker start yapi
Copy the code

Upgrade Yapi

1Stop and delete the old docker rm -f yapi2And get the latest image docker pull registry.cn-hangzhou.aliyuncs.com/anoy/yapi3, start the new container (the following commands are typed line by line as newlines) docker run -d --name yapi --link mongo-yapi:mongo --workdir/API /vendors -p3000:3000 \
	registry.cn-hangzhou.aliyuncs.com/anoy/yapi\
	server/app.js
Copy the code