1 Star 0 Fork 15

Mezh/花蕾-server

forked from sprouting/花蕾-server 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
.easy.api.config 6.36 KB
一键复制 编辑 原始数据 按行查看 历史
sprouting 提交于 2023-04-05 12:03 . 增加了easyYapi的配置
# ===================================================================
# 核心关键配置
# ===================================================================
# 设置API请求前缀
class.prefix.path=${server.servlet.context-path}
# 从api.name 中读取API的名称,默认使用api注释的第一行作为API的名称,使用的话就在注释里面,@api.name Mock String
# api.name=#api.name
# 标记接口是否公开,
# api.open=#open
# 设置忽略字段
constant.field.ignore=serialVersionUID
# 默认的所有含有默认初始值的字段, 取其默认初始值,加上下面的配置后,使用上,则可以用注解 @default 666
field.default.value=#default
# 用于生成yapi相关mock信息,使用 @mock 张三
field.mock=#mock
# 配置驼峰转下划线
# field.name=groovy:tool.camel2Underline(it.name())
# 用于标记字段是否为必须(即不可为空),这是针对model的
field.required=@"javax.validation.constraints.NotBlank
field.required=@javax.validation.constraints.NotNull
field.required=@javax.validation.constraints.NotEmpty
# 添加对swagger @ApiModelProperty支持
field.required=@io.swagger.annotations.ApiModelProperty#required
# 自定义注解
field.required=@com.sprouting.bud.common.annotations.invoke.CheckNotNull
# 用于标记API参数是否为必须(即不可为空)
param.required=@javax.validation.constraints.NotBlank
param.required=@"javax.validation.constraints.NotNull
param.required=@javax.validation.constraints.NotEmpty
# 添加对swagger @ApiParam支持
param.required=@io.swagger.annotations.ApiParam#required
# 字段的额外注释
#deprecated info(java)
field.doc[#deprecated]=groovy:"\n「已废弃」" + it.doc("deprecated")
field.doc[@java.lang.Deprecated]=「已废弃」
#deprecated info(kotlin)
field.doc[@kotlin.Deprecated]=groovy:"\n「已废弃」" + it.ann("kotlin.Deprecated","message")
# 添加对swagger @ApiModelProperty支持,不添加的话,则不会有多个注释信息
field.doc=@io.swagger.annotations.ApiModelProperty#value
# 用于忽略class/method, 不进行解析,注释在class上时,整个类将被忽略,注释在method上时,当前方法将被忽略,使用 @ignore
# ignore=#ignore
# 用于设置API请求默认的content-type, 插件依然会在必要的时候强行覆盖掉,如当遇到@RequestBody时, 将被强行覆盖为application/json。默认情况下, 插件优先使用application/x-www-form-urlencoded, 如希望优先使用multipart/form-data
# method.content.type=multipart/form-data
# 设置默认的api的HttpMethod,缺省情况下, 当API上未指定HttpMethod, 且无特殊参数时默认使用GET
# method.default.http.method=POST
# 参数示例信息,使用 如这个方法 public Object set(@RequestParam String newName) , 注释里面这么写 @demo newName tangcent
param.demo=groovy:it.method().doc("demo",it.name())
# 方法(API)的额外注释
# 默认推荐配置
method.doc[#deprecated]=groovy:"\n「已废弃」" + it.doc("deprecated")
method.doc[@java.lang.Deprecated]=「已废弃」
method.doc[groovy:it.containingClass().hasDoc("deprecated")]=groovy:"\n「已废弃」" + it.containingClass().doc("deprecated")
method.doc[groovy:it.containingClass().hasAnn("java.lang.Deprecated")]=「已废弃」
#deprecated info(kotlin)
method.doc[@kotlin.Deprecated]=groovy:"\n「已废弃」" + it.ann("kotlin.Deprecated","message")
method.doc[groovy:it.containingClass().hasAnn("kotlin.Deprecated")]=groovy:"\n「已废弃」 " + it.containingClass().ann("kotlin.Deprecated","message")
# 添加对swagger @ApiOperation支持
method.doc=@io.swagger.annotations.ApiOperation#value
# 标记接口tag
#yapi tag
api.tag[@java.lang.Deprecated]=deprecated
api.tag[#deprecated]=deprecated
api.tag[groovy:it.containingClass().hasAnn("java.lang.Deprecated")]=deprecated
api.tag[groovy:it.containingClass().hasDoc("deprecated")]=deprecated
#yapi tag for kotlin
api.tag[@kotlin.Deprecated]=deprecated
api.tag[groovy:it.containingClass().hasAnn("kotlin.Deprecated")]=deprecated
# 添加对swagger @ApiOperation支持
api.tag=@io.swagger.annotations.ApiOperation#tags
# ===================================================================
# 增加自定义mock规则
# ===================================================================
#mockjs官方示例: http://mockjs.com/examples.html
#定义一些基础的规则
#中国手机号
phone=1@pick(["34","35","36","37","38","39","50","5","52","58","59","57","82","87","88","70","47","30","3","32","55","56","85","86","33","53","80","89"])@string("number", 8)
#毫秒时间戳
mtimestamp=@now('T')
#0-9
digit=@natural(0,9)
#小于1000的自然数
natural_lt_1000=@natural(0,1000)
#小数点后两位
float_with_two=@natural(0,10000).@natural(0,100)
#http url
http_url=@pick(["http","https"])://www.@domain()/@string('lower',1,8)?@string('lower',2,4)=@string('number',1,2)
#objectId 只是字符和位数, 不满足具体协议
objectId=@string("0123456789abcdef",24,24)
# ===================================================================
# mock 的数据返回更自然
# ===================================================================
#常见的分页mock
mock.[*.p|integer]=1
mock.[*.l|integer]=@pick(["10","15","100"])
mock.[*.t|integer]=@natural(0,1000)
mock.[*.offset|integer]=1
mock.[*.page|integer]=1
mock.[*.pageIndex|integer]=1
mock.[*.pageSize|integer]=@pick(["10","15","100"])
mock.[*.limit|integer]=@pick(["10","15","100"])
mock.[*.total|integer]=@natural(0,1000)
# 整型的xxxTime mock为时间戳
mock.[*Time|integer]=${mtimestamp}
#性别
mock.[*.sex|integer]=@natural(0,2)
mock.[*.sex|string]=@pick(["男","女"])
mock.[*.gender|integer]=@natural(0,2)
mock.[*.gender|string]=@pick(["男","女"])
#用户信息相关
mock.[*.phone|string]=${phone}
mock.[*.mobile|string]=${phone}
mock.[*Phone|string]=${phone}
mock.[*Mobile|string]=${phone}
mock.[*.provinceName|string]=@province
mock.[*ProvinceName|string]=@province
mock.[*.cityName|string]=@city
mock.[*CityName|string]=@city
mock.[*.districtName|string]=@county
mock.[*DistrictName|string]=@county
mock.[*.address]=@cword(2,3)路@natural(1,1500)号
#链接
mock.[*.url|string]=${http_url}
mock.[*.link|string]=${http_url}
mock.[*.linkUrl|string]=${http_url}
mock.[*Link|string]=${http_url}
# integer和number更自然一些
mock.[*Type|integer]=${digit}
mock.[*Status|integer]=${digit}
mock.[*.type|integer]=${digit}
mock.[*.status|integer]=${digit}
mock.[*|integer]=@natural(0,10000)
mock.[*|number]=@float(0,10000)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/zhangshitou/bud-server.git
git@gitee.com:zhangshitou/bud-server.git
zhangshitou
bud-server
花蕾-server
master

搜索帮助