规则的key | 规则目标(上下文) | 版本 | 规则描述 |
---|---|---|---|
module | class | v0.7.2+ | 为api分组 |
ignore | class/method | v0.7.2+ | 忽略API |
json.rule.field.name | field | v0.7.2+ | 设置输出的字段名(用于json中字段名与类中字段名不一致) |
|
field | v0.7.2+ | 忽略字段(设置某些字段不出现在json中,或不需要请求时给出) 已废弃, 使用field.ignore代替 |
field.ignore | field | v2.0.0+ | 忽略字段(设置某些字段不出现在json中,或不需要请求时给出) |
☆json.rule.convert | - | v0.7.2+ | 用于设置某些类型转换为其他类型处理,通常用于使用了Spring的自定义类型转换器的情况 |
json.rule.enum.convert | class | v1.2.0+ | 用于枚举类型的特殊转换 |
☆field.doc | field | v0.7.2+ | 字段的额外注释 |
method.doc | method | v0.7.2+ | 方法(api)的额外注释 |
class.doc | class | v1.3.0+ | 类上的额外注释 |
param.doc | arg | v1.3.0+ | 参数的额外注释 |
param.required | arg | v0.7.3+ | API参数是否为必须(即不可为空) |
param.ignore | arg | v1.3.0+ | 忽略API参数 |
param.default.value | arg | v1.3.0+ | API参数的默认值 |
param.http.type | arg | v2.0.0+ | 用于设置API参数在HTTP请求中的类型 |
param.demo | - | v1.9.3+ | 用以设置参数的示例值 |
method.content.type | - | v1.9.7+ | 用以设置API请求的content-type |
method.default.http.method | method | v1.4.2+ | 设置默认的api的HttpMethod |
method.additional.header | method | v1.3.0+ | API需要额外的header |
{name: "header name",value: "",desc: "",required:false, example:""} | |||
method.additional.param | method | v1.3.0+ | API需要额外的参数 |
{name: "param name",value: "defaultValue",desc: "",required:false} | |||
method.additional.response.header | method | v1.3.0+ | API的响应包含额外的header |
{name: "header name",value: "",desc: "",required:false, example:""} | |||
field.required | field | v0.7.3+ | 字段是否为必须(即不可为空) |
☆field.mock | field | v1.4.2+ | 生成yapi mock信息 |
field.mock.resolveProperty | - | v1.4.2+ | 用以开关是否解析field.mock 规则结果中的占位符 |
field.default.value | - | v1.7.1+ | 用以设置字段的默认值 |
field.demo | - | v1.9.3+ | 用以设置字段的示例值 |
api.tag | method | v0.7.5+ | 标记接口tag |
api.open | method | v1.9.4+ | 标记接口是否公开 |
api.status | method | v0.8.0+ | 标记接口status(应返回done/undone) |
class.is.ctrl | method | v2.0.8+ | 允许导出指定类中的api |
mdoc.class.filter | class | v0.9.5+ | 选择哪些类可以导出方法文档(rpc) |
mdoc.method.filter | method | v0.9.5+ | 选择哪些方法可以导出方法文档(rpc) |
mdoc.method.path | method | v0.9.5+ | 设置方法文档(rpc)的路径 |
mdoc.method.http.method | method | v0.9.5+ | 设置方法文档(rpc)HTTP请求方式 |
class.prefix.path | class | v1.3.0+ | 设置API请求前缀 |
constant.field.ignore | field | v1.3.8+ | 忽略常量字段 |
☆method.return.main | method | v1.3.8+ | 设置返回值的核心主体 |
☆method.return | method | v1.6.1+ | 设置返回值的类型 |
api.name | method | v1.4.1+ | 设置api的名称 |
folder.name | method | v1.9.2+ | 设置api所属文件夹 |
path.multi | method | v1.9.2+ | 当API有多个路径时如何选择 |
postman.host | class | v1.5.2+ | 设置postman API的host |
postman.prerequest | class | v1.9.5+ | 设置postman API的prerequest |
class.postman.prerequest | class | v1.9.5+ | 设置postman·folder 上的prerequest |
collection.postman.prerequest | class | v1.9.5+ | 设置postman·collection 上的prerequest |
postman.test | class | v1.9.5+ | 设置postman API的test |
class.postman.test | class | v1.9.5+ | 设置postman·folder 上的test |
collection.postman.test | class | v1.9.5+ | 设置postman·collection 上的test |
http.call.before | request | v1.9.0+ | http请求前回调 |
http.call.after | request&response | v1.9.0+ | http请求后回调 |
NOTES:本地文件配置
# 读取注释上的tag
如 #fake
对应取的注释如下:
/**
* @fake
*/
@ 读取注解
@xxx 读取方法或字段上的注解,如@org.springframework.web.bind.annotation.RequestMapping
@RequestMapping("path")
public class FakeClass{...}
@xxx#yyy 读取方法或字段上的注解中的attr值,如@org.springframework.web.bind.annotation.RequestMapping#value
@RequestMapping(value = "path")
public class FakeClass{...}
JDK11
后js
引擎可能缺失,故推荐使用groovy
作为首选groovy
规则为 groovy:groovyScript
js
规则为 js:jsScript