idea 配置注释 和 Yapi 搭配

2019-11-22  本文已影响0人  _大叔_

关于YAPI的搭建

yapi使用传送门

2021/7/12 官方的安装失败,更换成docker 安装了 https://hub.docker.com/r/yapipro/yapi
在mongodb配置权限的时候,尽量全部权限给上。

方法注释

方法模板
*
 * 接口名称
 * 接口描述
 * @Author big uncle
 * @Date $date$ $time$
$param$
 * @return $return$
**/

注意事项
参数配置Edit variables
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+= ' * @param ' + params[i]  + ((i < params.size() - 1) ? '\\n':'')}; return result", methodParameters())
使用方法
/** 回车即可

类上的注释

类模板
/**
 * 所属Y-API 模块 
 * 模块描述 
 * @Author big uncle
 * @Date $date$ $time$
**/
参数

实际应用

package com.hyq.hyqcloud.controller;

import com.hyq.hyqcloud.entity.User;
import com.hyq.hyqcloud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 订单模块 // 这里对应你yapi 项目的模块名称
 * 这是一个新的订单模块 // 模块名称的描述
 * @Author big uncle
 * @Date 2019/11/22
 * @module HYQ_APP // 一定要写 而且对应的还是 yapi建的项目名
**/
@RestController
@RequestMapping("/user")
public class UserController {
    
    
    @Autowired
    private UserService userService;

    /**
     * getAllUser写方法中文名称
     * 这是一个getAllUser描述
     * @Author big uncle
     * @Date 2019/11/22 14:46
     * @param a
     * @return java.util.List<com.hyq.hyqcloud.entity.User>
    **/
    @GetMapping("/getAllUser")
    public List<User> getAllUser(String a){
        return userService.getAllUser();
    }

    /**
     * getUserById写方法中文名称
     * 这是一个getUserById描述
     * @Author big uncle
     * @Date 2019/11/22 14:47
     * @param
     * @return com.hyq.hyqcloud.entity.User
    **/
    @GetMapping("/getUserById")
    public User getUserById(){
        return userService.getUserById(1);
    }

}

idea插件推荐 EasyApi


token:项目名称=Token
可以配置多个,没配置一个要换行。

快速发布接口 alt + shift + e ,mac自己百度 拜拜

更新:
关于 easyapi 文档可以看这里:废了好大的劲找到,觉得可以给个赞

上一篇 下一篇

猜你喜欢

热点阅读