The company said before that it would establish a separate development model for front and back ends, but I just graduated, so I was responsible for establishing this specification. Although I have just graduated and have not been to a large factory, it is a challenge for me. Online programs are set up. I searched a lot of projects on Google and github, and finally found a good tool . As long as it is built on the intranet, it can perfectly solve some shortcomings of the separate development of the front and back ends. Build it below
1. Build Yapi database mongo
Direct docker command to start
docker run -d \
-p 27017:27017 \
--name mongo \
--restart=always \
-v /data/mongo:/data/db \
-e MONGO_INITDB_ROOT_USERNAME=mongo \
-e MONGO_INITDB_ROOT_PASSWORD=123456 \
mongo
2. Custom configuration file yapi-config.json
mkdir /data/yapi
vim /data/yapi/yapi-config.json
Fill in the configuration (change the account password yourself)
{
"port": "3000",
"adminAccount": "[email protected]",
"timeout": 120000,
"db": {
"servername": "mongo",
"DATABASE": "yapi",
"port": 27017,
"user": "mongo",
"pass": "123456",
"authSource": "admin"
}
}
3. Initialize the YAPI database index and administrator account
docker run -it --rm \
--link mongo:mongo \
--entrypoint npm \
--workdir /yapi/vendors \
-v /data/yapi/yapi-config.json:/yapi/config.json \
registry.cn-hangzhou.aliyuncs.com/anoyi/yapi \
run install-server
record password
4. Start the Yapi service
docker run -d \
--name yapi \
--restart=always \
--link mongo:mongo \
--workdir /yapi/vendors \
-p 9999:3000 \
-v /data/yapi/yapi-config.json:/yapi/config.json \
registry.cn-hangzhou.aliyuncs.com/anoyi/yapi \
server/app.js
5. Visit ip:9999 to log in to view
6. New project, interface test
Just find any json, paste it and save it
Automatically generate json, click mock to view
7. Summary
This tool is more suitable for simulating basic json. Advantages: It can generate corresponding formats by pasting various json, supports export and import, and supports many plug-ins . You can check it on the github document, and the supported plug-ins are quite complete. Disadvantage: It is necessary to manually change the simulation content, such as Chinese, time, etc.
YApi visual interface management platform
Experience address:
Documentation:
hellosean1025.github.io/yapi
Platform Introduction
YApi is an efficient, easy-to-use, and powerful API management platform designed to provide developers, products, and testers with more elegant interface management services. It can help developers easily create, publish, and maintain APIs. YApi also provides users with an excellent interactive experience. Developers only need to use the interface data writing tools provided by the platform and simple click operations to realize interface management.
characteristic
- Based on Json5 and Mockjs, define the structure and documents of the data returned by the interface, which improves the efficiency by multiple times
- Flat permission design not only ensures the management of large enterprise-level projects, but also ensures ease of use
- Interface debugging similar to postman
- Automated testing, support assertion on Response
- In addition to supporting ordinary random mocks, MockServer also adds the Mock expectation function, which returns expected data according to the set request filtering rules
- Support postman, har, swagger data import
- Free and open source, intranet deployment , no more fear of information leakage
Intranet deployment
Environmental requirements
- nodejs(7.6+)
- mongodb(2.6+)
- git
Install
Using the yapi-cli tool we provide, it is very easy to deploy the YApi platform. Execute the yapi server to start the visual deployment program, enter the corresponding configuration and click to start the deployment, and the deployment of the entire website can be completed. After the deployment is complete, follow the prompts to execute node/{site path/server/app.js} to start the server. Open the specified url in the browser, click Login and enter the administrator email address you just set, and the default password is ymfe.org to log in to the system (the default password can be modified in the personal center).
npm install -g yapi-cli --registry https://registry.npm.taobao.org
yapi server
service management
Use pm2 to facilitate service management and maintenance.
npm install pm2 -g //安装pm2
cd {项目目录}
pm2 start "vendors/server/app.js" --name yapi //pm2管理yapi服务
pm2 info yapi //查看服务信息
pm2 stop yapi //停止服务
pm2 restart yapi //重启服务
upgrade
It is very easy to upgrade the project version, and will not affect the existing project data, only the source code files in the vendors directory will be synchronized.
cd {项目目录}
yapi ls //查看版本号列表
yapi update //更新到最新版本
yapi update -v {Version} //更新到指定版本
tutorial
- Use YApi to manage API documentation, tests, mocks
- Automatically update Swagger interface data to YApi platform
- automated test
- GTest (based on YApi) interface research and development efficiency increased by 10 times
YApi plugin
- yapi sso login plugin
- yapi cas login plugin By wsfe
- yapi gitlab integration plugin
- oauth2.0 login
- Rap platform data import
- Dingding Dingding robot push plug-in
- export-docx-data data export docx document
- interface-oauth-token is a plug-in that automatically obtains the authentication token at regular intervals
- import-swagger-customize imports the specified swagger interface
code generation
- yapi-to-typescript: Generate TypeScript request function according to YApi interface definition
- yapi-gen-js-code: Generate javascript request function according to YApi interface definition
- SwiftJSOTModeler: Generate Swift model code according to YApi interface
YApi docker deployment (unofficial)
- Use the alpine version of the docker image to quickly deploy yapi
- docker-yapi: docker-compose solution based on official yapi-cli
- docker-compose one-click deployment of yapi
- docker-YApi: an easier-to-use YApi image
- Use Docker Compose to build and deploy Yapi
- yapi-docker: dockerized yapi deployment all in one
YApi some tools
- Api Generator interface document automatically generates plug-ins (zero intrusion)
- mysql service http tool, which can be used for automated testing
- idea one-click upload interface to yapi plugin
- idea interface upload debugging plug-in easy-yapi
- Execute postgres sql service
- SpringBoot relies on automatic generation of YApi
- Yapi X generates interface documents with one click, and uploads them to yapi, rap2, eolinker, etc. (IDEA plug-in)
Some clients of YApi
- where to
- Ctrip
- ELong
- meituan
- baidu
- Tencent
- alibaba
- Jingdong
- Today's headlines
- VipPay
- Lianjia.com
- quick worker
- convenience bee
- Zhongshanghuimin
- Sina
- VIPS
- Hornet's nest
- companion fish
- Megvii Technology
This article was originally created by " Cheng Ge Blog " and complies with the CC 4.0 BY-SA copyright agreement. For reprinting, please attach the original source link and this statement.
Original text link: front-end and back-end separation development tool YAPI deployment record