YAPI Docker安装, 以及gitlab登录插件
Yapi用默认的设置一切都挺好, 但是安装一些插件或自定义插件时, 坑就多了.
1. yapi安装
docker安装参考:https://gitee.com/fitop/docker-yapi
备注: github慢的话, 事先在Dockfile里面设置npm的源:
npm config set registry https://registry.npm.taobao.org
npm config get registry
2. 安装gitlab插件(要求yapi版本^1.8.8)
-
设置gitlab: 管理员登录->添加应用->授权api接口->设置yapi的回调->获取appId和appSecret
-
配置YAPI的config.json, 添加如下的plugins
"plugins": [{ "name": "gitlab", "options": { "host" : "Gitlab地址", "redirectUri" : "http://YAPI地址/api/plugin/oauth2/callback", "appId" : "XXXXX", "appSecret" : "XXXXX", "accessToken": "XXXXX", "loginPath": "/api/v4/user", "authPath" : "/oauth/authorize", "tokenPath" : "/oauth/token", "emailKey" : "email", "userKey" : "username", "emailPostfix" : "@yapi.com" } }]
-
npm插件: npm install https://gitee.com/zsjj/yapi-plugin-gitlab.git --save
-
重新编译: npm install build-client (N多的坑,参考:https://github.com/YMFE/yapi/pull/1937)
如果报: react/no-depr....错误, 参考https://github.com/YMFE/yapi/issues/1219
修改 .eslintrc.js的rules 增加 "react/no-deprecated": ["off"] 消除错误
如果swagger错误, 则将swagge-client版本锁定3.5.1 : npm install swagger-client@3.5.1 --save