# EasyYapi-example **Repository Path**: dxv5/easy-yapi-example ## Basic Information - **Project Name**: EasyYapi-example - **Description**: EasyYapi使用样例 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-05-25 - **Last Updated**: 2023-09-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README @toc # Yapi接口管理系统 ## 环境配置 **软件版本** + windows 11 + docker 20.10.21 + docker-compose 2.15.0 + docker-Yapi 1.12.0 + IDEA 2021.2 + EasyYapi 2.5.8 **参考链接** + [docker离线安装](https://blog.csdn.net/qq_27706119/article/details/122311325) + [docker-compose离线安装](https://www.jianshu.com/p/6f9ce31b9aa7) + [docker-Yapi安装](https://gitee.com/fjc0k/docker-YApi) + [EasyYapi介绍文档](http://easyyapi.com/documents/export2yapi.html) + [YApi介绍文档](https://hellosean1025.github.io/yapi/documents/index.html) + [Swagger介绍文档](https://blog.csdn.net/Littewood/article/details/128819149) + [Swagger注解介绍文档](https://github.com/swagger-api/swagger-core/wiki/Annotations) ## 使用Yapi ### 安装Yapi > 为了简化安装,此处采用docker镜像安装Yapi, 请确保电脑系统安装有docker、docker-compose **拉取项目** ```shell git clone https://gitee.com/fjc0k/docker-YApi.git ``` **编排镜像** ```shell cd docker-YApi docker-compose up -d ``` **进入系统** 在浏览器输入系统地址:`http://{yapi_deploy_host}:40001`,使用邮箱登录,输入管理员初始的账号和密码(`admin@docker.yapi`/`adm1n`),完成Yapi的安装。 ![账号登录](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/login.png) ### 添加接口 依次点击`添加项目` > `添加接口`,填写完接口信息,保存后完成接口的添加。 ![添加项目](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/project_add.png) ![添加接口](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/interface_add.png) 或者点击`添加项目` > `数据管理` > `数据导入`,完成接口的添加。 ![数据接口](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/interface_import.png) ### 项目权限 > 新用户未加入项目或分组时,我们称为 `“游客”`。注意:如果是在`项目`页面添加的用户,该用户拥有分组权限`“游客”`,可以看到组内的所有项目。 **项目权限** | 操作 | 游客 | 项目开发者 | 项目组长 | 超级管理员 | | --- | --- | --- | --- | --- | | 浏览公开项目与接口 | ✓ | ✓ | ✓ | ✓ | | 浏览私有项目与接口 | | ✓ | ✓ | ✓ | | 编辑项目信息 | | ✓ | ✓ | ✓ | | 新建接口 | | ✓ | ✓ | ✓ | | 编辑接口 | | ✓ | ✓ | ✓ | | 编辑项目头像 | | | ✓ | ✓ | | 删除项目 | | | ✓ | ✓ | **分组权限** | 操作 | 游客 | 分组开发者 | 分组组长 | 超级管理员 | | --- | --- | --- | --- | --- | | 浏览分组 | ✓ | ✓ | ✓ | ✓ | | 在分组中新建项目 | | ✓ | ✓ | ✓ | | 编辑分组信息 | | | ✓ | ✓ | | 管理分组成员 | | | ✓ | ✓ | | 删除分组 | | | ✓ | ✓ | ## 使用EasyYapi > Yapi可以识别注释里的描述和注解,生成的接口信息更为丰富,代码入侵性小 ### 安装和通用配置 1. 打开IDEA,依次点击`Preferences(Settings)` > `Plugins` ,搜索`EasyYapi`,并进行安装 ![EasyYapi安装](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/easyyapi-install.png) 2. 打开IDEA,依次点击`Preferences(Settings)` > `Other Settings` > `EasyYapi`,找到Yapi栏目,进行以下配置。 | 配置项 | 值 | 说明 | | --------- | -------- | ----- | | server | {yapi_deploy_host}:40001 | Yapi的访问地址 | | tokens | {module}={token} | 将本地项目和Yapi的项目关联起来。多组数据换行填写 | ![EasyYapi配置](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/easyyapi-config.png) 3. `Recommond`可按需勾选,`Remote`建议全部勾选。 ![EasyYapi推荐配置](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/easyyapi-recommond.png) ![EasyYapi远程配置](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/easyyapi-remote.png) ### 导入接口到Yapi 对项目名、包名、类名、方法右键,选择`EasyApi` > `Export Yapi` 或 `Export Api`。若弹窗要求输入token, 可去Yapi页面`设置` > `token配置`查看目标项目的token。 ![EasyYapi导出接口](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/easyyapi-export.png) ![EasyYapi的token](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/easyyapi-token.png) 点击`接口` > `接口列表`,可以看到导入的接口了。 ![接口列表](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/interface-list.png) ![接口明细](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/interface-detail.png) ![接口明细2](https://gitee.com/dxv5/easy-yapi-example/raw/master/image/interface-detail2.png)