Skip to content
forked from YMFE/yapi

YApi 是一个可本地部署的、打通前后端及QA的、可视化的接口管理平台

License

Notifications You must be signed in to change notification settings

ahuinee/yapi-free-mock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YApi-自由 Mock

为了方便使用,同时也是我们的需求:定义多个入参相同出参不同的 Mock,通过开启和关闭 Mock 来控制

修改 yapi/vendors/exts/yapi-plugin-advanced-mock/controller.js

findRepeatParams = {
  project_id: data.project_id,
  interface_id: data.interface_id,
  ip_enable: data.ip_enable,
  // 添加一个name的检查条件,允许添加相同入参期望名称不同的Mock
  name: data.name
};

为了方便部署,添加 Docker 支持

修改 config-yapi.json

{
  "port": "3000",
  "adminAccount": "[email protected]",
  "timeout": 120000,
  "db": {
    "servername": "mongo",
    "DATABASE": "yapi",
    "port": 27017,
    "user": "root",
    "pass": "chenhui",
    "authSource": "admin"
  },
  "mail": {
    "enable": false
  },
  "closeRegister": false
}

docker-compose.yml

version: '3.9'
services:
  mongo:
    image: mongo
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: root

  yapi:
    # image: ahuinee/yapi-free-mock:latest
    build: .
    restart: always
    volumes:
      - ./config-yapi.json:/yapi/config.json
    depends_on:
      - mongo
    ports:
      - 3000:3000

初始化管理员(如果已经初始化就不需要这一步) 进入 Dokcer 容器然后执行

/yapi/vendors # npm run install-server

重启容器即可

About

YApi 是一个可本地部署的、打通前后端及QA的、可视化的接口管理平台

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 91.0%
  • SCSS 7.2%
  • Other 1.8%