Giter VIP home page Giter VIP logo

yapi-x's Introduction

YApi-X

YApi-X 基于 YApi v1.8.8 开发,相较原版,有以下改动:

  • 接口路径支持更多字符,可以将 @#; 等字符用于接口路径定义;
  • 支持复制分类;
  • 新增 adminPassword 配置项以设置管理员密码;
  • 项目图标支持自传图片;
  • 接口运行支持上传文件(需安装插件 →);
  • 请求参数设置下的 Headers 支持批量添加;
  • 支持 webdav 扩展的 HTTP 请求方法 PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK(了解更多 →);
  • 支持为路径参数、查询参数设置类型。

如何安装

为了节省各自的时间,推荐你使用 Docker 安装,同时本文档也不会介绍其他安装方式。

YApi-X 镜像

通过 Docker Compose 安装

以下是一个示例:

version: '3'

services:
  yapi-web:
    image: jayfong/yapi-x:latest
    container_name: yapi-web
    ports:
      - 40001:3000
    environment:
      - [email protected]
      - YAPI_ADMIN_PASSWORD=adm1n
      - YAPI_CLOSE_REGISTER=true
      - YAPI_DB_SERVERNAME=yapi-mongo
      - YAPI_DB_PORT=27017
      - YAPI_DB_DATABASE=yapi
      - YAPI_MAIL_ENABLE=false
      - YAPI_LDAP_LOGIN_ENABLE=false
      - YAPI_PLUGINS=[]
    depends_on:
      - yapi-mongo
    links:
      - yapi-mongo
    restart: unless-stopped
  yapi-mongo:
    image: mongo:latest
    container_name: yapi-mongo
    volumes:
      - ./data/db:/data/db
    expose:
      - 27017
    restart: unless-stopped

运行

将上面的示例复制粘贴下来命名为 docker-compose.yml,使用以下命令运行:

docker-compose up -d

然后,通过 http://localhost:40001 即可访问 YApi-X

重启

若你修改了配置,务必重启应用才能生效:

docker-compose restart yapi-web

升级

YApi-X 一旦有更新,你可通过以下命令升级:

docker-compose pull yapi-web \
  && docker-compose down \
  && docker-compose up -d

升级不会对原有数据造成任何影响!

迁移

直接打包整个目录去新的服务器即可。

日志

如果出现意外情况,你可通过以下命令查看运行日志:

docker-compose logs yapi-web

如何配置

你可通过环境变量进行配置。

基础配置

环境变量名称 类型 说明 示例
YAPI_ADMIN_ACCOUNT string 管理员账号(邮箱) [email protected]
YAPI_ADMIN_PASSWORD string 管理员密码 adm1n
YAPI_CLOSE_REGISTER boolean 是否关闭注册 true

数据库配置

环境变量名称 类型 说明 示例
YAPI_DB_SERVERNAME string MongoDB 服务地址 yapi-mongo
YAPI_DB_PORT number MongoDB 服务端口 27017
YAPI_DB_DATABASE string 使用的 MongoDB 数据库 yapi
YAPI_DB_USER string 登录 MongoDB 服务的用户名 root
YAPI_DB_PASS string 登录 MongoDB 服务的用户密码 r00t
YAPI_DB_AUTH_SOURCE string MongoDB 身份认证所用库 admin
YAPI_DB_CONNECT_STRING string 使用 MongoDB 集群时配置 mongodb://127.0.0.100:8418,127.0.0.101:8418/yapidb?slaveOk=true
YAPI_DB_OPTIONS json Mongoose 连接 MongoDB 服务时的额外选项,一般不用设置。请参考: Mongoose.prototype.connect() {}

邮件配置

环境变量名称 类型 说明 示例
YAPI_MAIL_ENABLE boolean 是否启用 true
YAPI_MAIL_HOST string 邮件服务地址 smtp.163.com
YAPI_MAIL_PORT number 邮件服务端口 465
YAPI_MAIL_FROM string 发送人邮箱 [email protected]
YAPI_MAIL_AUTH_USER string 登录邮件服务的用户名 [email protected]
YAPI_MAIL_AUTH_PASS string 登录邮件服务的用户密码 f00bar
YAPI_MAIL_OPTIONS json 传递给 Nodemailer 的额外选项,一般不用设置。请参考:Nodemailer > SMTP transport {"tls":{"rejectUnauthorized":false}}

LDAP 登录配置

环境变量名称 类型 说明 示例
YAPI_LDAP_LOGIN_ENABLE boolean 是否启用 true
YAPI_LDAP_LOGIN_SERVER string LDAP 服务地址 ldap://ldap.foo.bar
YAPI_LDAP_LOGIN_BASE_DN string 登录 LDAP 服务的用户名 cn=admin,dc=foo,dc=bar
YAPI_LDAP_LOGIN_BIND_PASSWORD string 登录 LDAP 服务的用户密码 f00bar
YAPI_LDAP_LOGIN_SEARCH_DN string 查询用户数据的路径 ou=users,dc=foo,dc=bar
YAPI_LDAP_LOGIN_SEARCH_STANDARD string 支持两种值:
1、前端登录账号对应的查询字段,如:mailuid 等;
2、自定义查询条件,其中 %s 会被前端登录账号替换,如:&(objectClass=user)(cn=%s)
-
YAPI_LDAP_LOGIN_EMAIL_POSTFIX string 登录邮箱后缀 @163.com
YAPI_LDAP_LOGIN_EMAIL_KEY string LDAP 数据库存储用户邮箱的字段 mail
YAPI_LDAP_LOGIN_USERNAME_KEY string LDAP 数据库存储用户名的字段 name

插件配置

环境变量名称 类型 说明 示例
YAPI_PLUGINS json 要使用的插件列表。点击查看开源 YApi 插件列表 →
配置项数据格式:
{
    "name": "插件名称",
    "options": "插件配置"
}
注意:
安装插件会运行 YApi 自带的打包命令,其内存消耗较大,因此,在安装插件时,物理机可用内存最好大于 1GB,否则,易出现内存溢出错误,导致插件安装失败。
[{"name":"add-user"},{"name":"gitlab","options":{}}]

yapi-x's People

Contributors

fjc0k avatar nick-duan avatar staceyzhou2017 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yapi-x's Issues

科学计数法

1、在返回的响应中,返回数据正确。
{"code":0,"data":{"name":"WorldRoleListResponse","data":{"roleList":[{"playerId":108087106890940705}]}},"msg":"发送请求成功"}

2、通过获取响应包体中数据,填充到下一个请求中。发出的请求,显示为:108087106890940700,wireshark抓包也显示如此。
{{ $.40534.body.data.data.roleList[0].playerId }}

第一个请求的响应:
image

第二个请求:
image

第二个请求显示:
image

请问是否可以添加npm的安装说明

公司服务器只提供了传统的单体虚拟机环境。在可预见的未来,也不会提供其它方式的服务器。请问有空的时候,在文档中,能否类似于官网,补充npm的安装方式。

接口路径不能重复

对于某些项目
比如我这个, 他的设定是接口路径唯一, 然后根据请求参数来判断走哪个接口的.
我现在想新增接口, 但是提示我已经存在相同路径接口且找不到地方可以修改这个限制...

同学,您这个项目引入了1262个开源组件,存在63个漏洞,辛苦升级一下

检测到 fjc0k/YApi-X 一共引入了1262个开源组件,存在63个漏洞

漏洞标题:serialize-javascript 代码问题漏洞
缺陷组件:[email protected]
漏洞编号:CVE-2020-7660
漏洞描述:Verizon serialize-javascript是美国威瑞森电信(Verizon)公司的一款支持将JavaScript序列化为 JSON超集的软件包。
serialize-javascript 3.1.0之前版本中存在代码问题漏洞。远程攻击者可借助index.js文件中的‘deleteFunctions’函数利用该漏洞注入任意代码。
国家漏洞库信息:https://www.cnvd.org.cn/flaw/show/CNVD-2020-53801
影响范围:(∞, 3.1.0)
最小修复版本:3.1.0
缺陷组件引入路径:[email protected]>[email protected]>[email protected]
[email protected]>[email protected]>[email protected]

另外还有63个漏洞,详细报告:https://mofeisec.com/jr?p=i2cfd0

yapi的mock漏洞

测试yapi-x也受到影响,yapi目前最新代码已经更新补丁,希望能及时跟进。

测试集合中,是否支持文件上传功能

在官方的版本,对于文件上传功能,文件上传接口选择了文件,再切换到该接口运行或者运行测试集合时候,文件就不存在了。请问这个版本是否支持测试集合中的文件上传吗?

接口无法调试

image

image

我已经装了插件,可是dev-tools里面一直没请求出去, 也没返回. 接口不能请求,已经按正常配置

console里面一直报错 runtime.js:1 Uncaught (in promise) TypeError: Failed to fetch

是不是要做什么特殊配置

使用更新命令之后启动失败

log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined
at Object. (/yapi/vendors/node_modules/yapi-plugin-gitlab/server.js:30:32)
at Object.emitHook (/yapi/vendors/server/plugin.js:224:57)
at Object. (/yapi/vendors/server/router.js:601:6)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object. (/yapi/vendors/server/app.js:20:16)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
log: mongodb load success...

使用url导入swagger数据时报错

  1. 定时自动导入会错,错误如下:
[sever] log: -------------------------------------swaggerSyncUtils constructor-----------------------------------------------
[sever] log: 服务已启动,请打开下面链接访问: 
[sever] http://127.0.0.1:3000/
[sever] log: mongodb load success...
[sever] log: 定时器触发, syncJsonUrl:http://9.148.163.161/swagger,合并模式:good
[sever] (node:1121) [DEP0106] DeprecationWarning: crypto.createCipher is deprecated.
[sever] (node:1121) UnhandledPromiseRejectionWarning: TypeError: operation[inheritName].some is not a function
[sever]     at _loop2 (/Users/nickduan/Documents/UGit/YApi-X/node_modules/swagger-client/dist/index.js:2635:57)
[sever]     at _loop (/Users/nickduan/Documents/UGit/YApi-X/node_modules/swagger-client/dist/index.js:2644:198)
[sever]     at normalizeSwagger (/Users/nickduan/Documents/UGit/YApi-X/node_modules/swagger-client/dist/index.js:2650:47)
[sever]     at processTicksAndRejections (internal/process/task_queues.js:97:5)
[sever] (node:1121) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[sever] (node:1121) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  1. 直接swagger导入没反应,一直loading,且接口也没有导入。如图
    image

docker-compose起容器的时区问题

compose起镜像的时区能修改为宿主机器的时区吗?
自动化测试设置的时间与容器时间相同,与宿主机不同,导致执行时间需要人工加减计算

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.