Yapi is a free and powerful development, product and test interface management tool

Posted by Silver_Eclipse on Fri, 10 Dec 2021 05:46:16 +0100

Yapi provides more elegant interface management services for developers, products and testers. It can help developers easily create, publish and maintain API s.

Functional features:

Authority management

YApi's mature team management and flat project authority configuration meet the needs of various enterprises

Visual interface management

The editing function of multi person collaboration interface based on websocket and postman like testing tool enable multi person collaboration to double the development efficiency

Mock Server

Easy to use Mock Server, no longer need to worry about the generation of mock data

automated testing

Perfect interface automatic test to ensure the correctness of data

Data import

It supports importing swagger, postman and har data formats to facilitate the migration of old projects

Plug in mechanism

Powerful plug-in mechanism to meet various business needs

Privatization deployment

Using the YApi cli tool, it is very easy to deploy the YApi platform. It is recommended to deploy to an http site. Due to the security restrictions of the chrome browser, deploying to https will cause the file upload function of the test function to be abnormal when requesting an http site.

Environmental requirements

  • nodejs(7.6+)
  • mongodb(2.6+)

Deploy nodejs environment

Download the nodejs deployment package and unzip it

cd /usr/local/
wget https://nodejs.org/dist/v13.6.0/node-v13.6.0-linux-x64.tar.gz
tar -xvf node-v13.6.0-linux-x64.tar.gz
mv node-v13.6.0-linux-x64.tar.gz nodejs

Create soft connection

# Establish node soft link
ln -s /usr/local/nodejs/bin/node /usr/local/bin
# Establish npm soft link
ln -s /usr/local/nodejs/bin/npm /usr/local/bin

Replace mirror source

# Set domestic Taobao image source
npm config set registry https://registry.npm.taobao.org
# View setup information
npm config list

Mirror source replaced

[root@localhost ~]# npm config list
; cli configs
metrics-registry = "https://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.13.4 node/v13.6.0 linux x64"

; userconfig /root/.npmrc
registry = "https://registry.npm.taobao.org/"

; node bin location = /usr/local/nodejs/bin/node
; cwd = /root
; HOME = /root
; "npm config ls -l" to show all defaults.
[root@localhost ~]# 

Verify and view version

[root@localhost ~]# node -v
v13.6.0
[root@localhost ~]# npm -v
6.13.4
[root@localhost ~]# 

From the above, you can see that the nodejs environment has been installed

Deploy mongodb database

Download address:

https://www.mongodb.com/download-center/community

Download and unzip

cd /usr/local/
tar -xvf mongodb-linux-x86_64-rhel70-5.0.5.tgz
mv mongodb-linux-x86_64-rhel70-5.0.5 mongodb

create folder

mkdir -p ./data/db
mkdir -p ./logs
mkdir ./conf
[root@localhost mongodb]# ll
total 132
drwxr-xr-x 2 root root    70 Dec  8 20:52 bin
drwxr-xr-x 2 root root    25 Dec  8 20:54 conf
drwxr-xr-x 3 root root    16 Dec  8 20:53 data
-rw-r--r-- 1 root root 30608 Dec  2 23:33 LICENSE-Community.txt
drwxr-xr-x 2 root root    24 Dec  8 20:55 logs
-rw-r--r-- 1 root root 16726 Dec  2 23:33 MPL-2
-rw-r--r-- 1 root root  1977 Dec  2 23:33 README
-rw-r--r-- 1 root root 76823 Dec  2 23:33 THIRD-PARTY-NOTICES
[root@localhost mongodb]# 

Create a configuration file and modify the corresponding path

vim ./conf/mongod.conf

 systemLog:
#mongodb sends all log output to a specified file
    destination: file
#The path of the log file to which mongod or mongos should send all diagnostic logging information
    path: /usr/local/mongodb/logs/mongod.log
#When a mongos or mongod instance restarts, it appends a new entry to the end of the existing log file.
    logAppend: true
 storage:
#The directory where the mongod instance stores its data. storage. The dbpath setting applies only to mongod.
    dbPath: /usr/local/mongodb/data/db
    journal:
#Enable or disable persistent logging to ensure that data files remain valid and recoverable.
        enabled: true
 processManagement:
#Enable daemon mode for running mongos or mongod processes in the background.
    fork: true
 net:
#The IP bound to the service instance is localhost by default. For external access, you should add LAN IP instead of public IP
    bindIp: localhost,192.168.2.224
#The bound port is 27017 by default
    port: 27017

start-up

[root@localhost bin]# ./mongod -f ../conf/mongod.conf 
about to fork child process, waiting until server is ready for connections.
forked process: 1424
child process started successfully, parent exiting

Seeing the child process started successfully indicates that it has been started successfully

Deploy Yapi services

Execute yapi server, start the visual deployment program, enter the corresponding configuration and click Start deployment to complete the deployment of the whole website. After deployment, execute node / {website path / server/app.js} to start the server according to the prompt. Open the specified url in the browser, click login, enter the administrator email you just set, and log in to the system with the default password (ymfe.org) (the default password can be modified in the personal Center).

npm install -g yapi-cli --registry https://registry.npm.taobao.org
yapi server

Open in browser http://0.0.0.0:9090 visit. Non local server, please set 0.0 Replace 0.0 with the specified domain name or ip address

Browser access: ip:9090

Enter the company name and click Start deployment

Dependency library installation completed, initializing database mongodb...
 > yapi-vendor@1.10.2 install-server /usr/local/nodejs/bin/my-yapi/vendors
>  node server/install.js
log: mongodb load success...
Initialization of administrator account succeeded,Account Name:"admin@admin.com",password:"ymfe.org"
If the deployment is successful, please switch to the deployment directory and enter: "node vendors/server/app.js" Command start server
 Then open it in the browser http://127.0. 0.1:3000 access

After installation and deployment, go to the server deployment directory

/usr/local/nodejs/bin/my-yapi

Enter start command

node vendors/server/app.js
[root@localhost my-yapi]# node vendors/server/app.js
log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
log: The service has been started. Please open the link below to visit: 
http://127.0.0.1:3000/
log: mongodb load success...
(node:1588) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(node:1588) DeprecationWarning: collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.

Browser access: ip:3000

Initialization of administrator account succeeded. Account name:“ admin@admin.com ", password:" ymfe.org“