高效、易用、功能强大的 api 管理平台

前言导读

实际环境的需求可以说是:只有你没想到,没有实现不了的,征对于目前实际开发、测试、生产等环境中,需要用到各类的接口可达几十、甚至上百个,因此,必须需要一个统一管理的工具平台来统一管理这类接口,从而方便后续使用。
那么今天来简单介绍下开源的接口管理工具:YApi

平台介绍

官方网站:https://yapi.ymfe.org/index.html
Github地址:https://github.com/YMFE/yapi

YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 API,YApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。

特性

1、基于 Json5 和 Mockjs 定义接口返回数据的结构和文档,效率提升多倍
2、扁平化权限设计,即保证了大型企业级项目的管理,又保证了易用性
3、类似 postman 的接口调试
4、自动化测试, 支持对 Response 断言
5、MockServer 除支持普通的随机 mock 外,还增加了 Mock 期望功能,根据设置的请求过滤规则,返回期望数据
6、支持 postman, har, swagger 数据导入
7、免费开源,内网部署,信息再也不怕泄露了

安装环境介绍与布署

环境要求(centos安装环境)
nodejs(7.6+)
mongodb(2.6+)

安装 Node.js

[root@tools-server ~]# curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
[root@tools-server ~]# yum -y install nodejs
[root@tools-server ~]# yum install gcc-c++ make -y

安装配置MogoDB数据库

[root@tools-server ~]# cd /etc/yum.repos.d/
[root@tools-server yum.repos.d]# vim mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
[root@tools-server ~]# yum install mongodb-org -y

启动服务

[root@tools-server ~]# service mongod start
Starting mongod (via systemctl):    [  确定  ]
[root@tools-server ~]# ps -ef|grep mongod
mongod 10549 1 0 11:00 ? 00:00:00 /usr/bin/mongod -f /etc/mongod.conf
root 10563  1291 0 11:00 pts/0  00:00:00 grep --color=auto mongod
[root@tools-server ~]# lsof -i :27017
COMMAND PID  USER  FD  TYPE DEVICE SIZE/OFF NODE NAME
mongod 10549 mongod 8uIPv4 28721 0t0 TCP localhost:27017 (LISTEN)

创建数据库

[root@tools-server ~]# mongo
MongoDB shell version: 2.6.12
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
       http://docs.mongodb.org/
Questions? Try the support group
       http://groups.google.com/group/mongodb-user
> use yapi
switched to db yapi
> db.wong.insert({"name":"kenny wong"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin  (empty)
local  0.078GB
yapi   0.078GB
> db.addUser('yapi','yapi321')
WARNING: The 'addUser' shell helper is DEPRECATED. Please use 'createUser' instead
Successfully added user: { "user" : "yapi", "roles" : [ "dbOwner" ] }

安装与配置YApi工具

安装yapi软件

[root@tools-server ~]# mkdir yapi
[root@tools-server ~]# cd yapi/
[root@tools-server yapi]# git clone https://github.com/YMFE/yapi.git vendors
如果下载较慢,可直接下载压缩包进行解压

[root@tools-server yapi-master]# cp config_example.json ../config.json 
[root@tools-server yapi-master]# vim config.json
 {
"port": "3000",
"adminAccount": "admin@admin.com",
"db": {
"servername": "127.0.0.1",
"DATABASE":  "yapi",
 "port": 27017,
"user": "yapi",
"pass": "yapi321"
},
"mail": {
 "enable": true,
"host": "smtp.163.com",
 "port": 465,
 "from": "***@163.com",
 "auth": {
 "user": "***@163.com",
"pass": "*****"
}
}
}

[root@tools-server yapi-master]# npm install --production --registry https://registry.npm.taobao.org

启动服务


WEB登陆


具体一些后面接口与项目操作,可以参考官方文档

©著作权归作者所有:来自作者民工哥的原创作品,如需转载,请注明出处,否则将追究法律责任

原文地址:https://www.cnblogs.com/youkanyouxiao/p/9850362.html