用于设置API名称
缺省情况下, 默认使用api注释的第一行作为API的名称
# read api name from tag `api.name`
api.name=#api.name标记接口 status
api.status=#status标记接口 tag
api.tag=@io.swagger.annotations.ApiOperation#tags默认的只会导出注解有 org.springframework.stereotype.Controller或org.springframework.web.bind.annotation.RestController的类中的api.
当有导出未注解 org.springframework.stereotype.Controller或org.springframework.web.bind.annotation.RestController的类中的api的需求时,可以配置此规则
apiclass.is.ctrl=truectrl类中的api@ctrl来控制哪些类会包含api, 可以配置为:class.is.ctrl=#ctrl设置API请求前缀
#Resolve spring properties
###set ignoreUnresolved = true
class.prefix.path=${server.servlet.context-path}
###set ignoreUnresolved = falseserver.servlet.context-path=/demoserver:
servlet:
context-path: /democlass.prefix.path=/demo忽略常量字段
#ignore serialVersionUID
constant.field.ignore=serialVersionUID#ignore serialVersionUID
constant.field.ignore=groovy:it.name()=="serialVersionUID"@see com.itangcent.common.constant.UserTypeConstant{@link com.itangcent.common.constant.UserTypeConstant}枚举: 1,2,3
枚举备注: 1 :管理员 2 :成员 3 :游客
mock: @pick(["1","2","3"])用于设置使用 @see枚举类型时的默认取值字段
public enum UserType {
//管理员
ADMIN(1, "管理员"),
//成员
MEMBER(2, "成员"),
//游客
GUEST(3, "游客");
private int code;
private String desc;
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
UserType(int code, String desc) {
this.code = code;
this.desc = desc;
}
}@see UserType时默认使用code字段作为取值enum.use.custom[com.itangcent.common.constant.UserType]=code| 名称 | 类型 | 是否必须 | 默认值 | 备注 | 其他信息 |
|---|---|---|---|---|---|
| type | integer | 非必须 | 用户类型 | 枚举: 1,2,3 枚举备注: 1: 管理员 2: 成员 3: 游客 mock: @pick([1,2,3]) |
package com.itangcent.common.constant;
public interface BaseEnum {
Long getCode();
}UserType,使其继承BaseEnumpublic enum UserType implements BaseEnum {
...
}BaseEnum的类默认使用code字段作为取值enum.use.custom[groovy:it.isExtend("com.itangcent.common.constant.BaseEnum")]=code默认使用类型一致的字段, 优先级低于 enum.use.custom
public enum UserType {
//管理员
ADMIN(1, "管理员"),
//成员
MEMBER(2, "成员"),
//游客
GUEST(3, "游客");
private int code;
private String desc;
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
UserType(int code, String desc) {
this.code = code;
this.desc = desc;
}
}enum.use.by.type=true| 名称 | 类型 | 是否必须 | 默认值 | 备注 | 其他信息 |
|---|---|---|---|---|---|
| type | integer | 非必须 | 用户类型 | 枚举: 1,2,3 枚举备注: 1: 管理员 2: 成员 3: 游客 mock: @pick([1,2,3]) |
用于设置使用 @see枚举类型时的默认使用ordinal作为取值
优先级低于 enum.use.custom和enum.use.by.type
所以要使用 enum.use.ordinal需要先在推荐配置中取消enum.use.by.type
public enum UserType {
//管理员
ADMIN(1, "管理员"),
//成员
MEMBER(2, "成员"),
//游客
GUEST(3, "游客");
private int code;
private String desc;
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
UserType(int code, String desc) {
this.code = code;
this.desc = desc;
}
}@see UserType会被忽略掉@see UserType时默认使用ordinal字段作为取值enum.use.ordinal[com.itangcent.common.constant.UserType]=true| 名称 | 类型 | 是否必须 | 默认值 | 备注 | 其他信息 |
|---|---|---|---|---|---|
| type | integer | 非必须 | 用户类型 | 枚举: 1,2,3 枚举备注: 1: 管理员 2: 成员 3: 游客 mock: @pick([1,2,3]) |
package com.itangcent.common.constant;
public interface BaseEnum {
}UserType,使其继承BaseEnumpublic enum UserType implements BaseEnum {
...
}BaseEnum的类默认使用ordinal作为取值enum.use.ordinal[groovy:it.isExtend("com.itangcent.common.constant.BaseEnum")]=true@see枚举类都默认使用ordinal作为取值enum.use.ordinal=true用于设置使用 @see枚举类型时的默认使用name作为取值
优先级低于 enum.use.custom和enum.use.by.type
所以要使用 enum.use.name需要先在推荐配置中取消enum.use.by.type
public enum UserType {
//管理员
ADMIN(1, "管理员"),
//成员
MEMBER(2, "成员"),
//游客
GUEST(3, "游客");
private int code;
private String desc;
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
UserType(int code, String desc) {
this.code = code;
this.desc = desc;
}
}@see UserType会被忽略掉@see UserType时默认使用name字段作为取值enum.use.name[com.itangcent.common.constant.UserType]=true| 名称 | 类型 | 是否必须 | 默认值 | 备注 | 其他信息 |
|---|---|---|---|---|---|
| type | string | 非必须 | 用户类型 | 枚举: ADMIN, MEMBER, GUEST 枚举备注: ADMIN: 管理员 MEMBER: 成员 GUEST: 游客 mock: @pick([ADMIN,MEMBER,GUEST]) |
package com.itangcent.common.constant;
public interface BaseEnum {
}UserType,使其继承BaseEnumpublic enum UserType implements BaseEnum {
...
}BaseEnum的类默认使用name作为取值enum.use.name[groovy:it.isExtend("com.itangcent.common.constant.BaseEnum")]=true@see枚举类都默认使用name作为取值enum.use.name=true用于设置 字段的默认值
private Integer code = 200;//响应码field.default.value=#defaultpublic class DemoDto{
/**
* 价格
* @default 666
*/
@NotNull
private Float price;
...
}| 名称 | 类型 | 是否必须 | 默认值 | 备注 | 其他信息 |
|---|---|---|---|---|---|
| price | number | 必须 | 666 | 价格 |
字段示例信息
field.demo=#demo /**
* @demo tangcent
*/
private String name;//用户名字段的额外注释
#deprecated info(java)
field.description[#deprecated]=groovy:"\n「已废弃」" + it.description("deprecated")
field.description[@java.lang.Deprecated]=「已废弃」
#deprecated info(kotlin)
field.description[@kotlin.Deprecated]=groovy:"\n「已废弃」" + it.ann("kotlin.Deprecated","message")
field.description=@io.swagger.annotations.ApiModelProperty#valuepublic class SwaggerModel {
/**
* @deprecated 不再使用
*/
@ApiModelProperty(value = "字段A", required = true)
private String a;
//constructors...
//getters...
}| 名称 | 类型 | 是否必须 | 默认值 | 备注 | 其他信息 |
|---|---|---|---|---|---|
| a | string | 非必须 | 666 | 字段A「已废弃」不再使用 |
忽略字段(设置某些字段不出现在json中,或不需要请求时给出)
#Support for Jackson annotations
field.ignore=@com.fasterxml.jackson.annotation.JsonIgnore#value
#Support for Gson annotations
field.ignore=!@com.google.gson.annotations.Expose#serializepublic class TestJsonIgnoreBean {
@Expose(serialize = true)
private Long shouldNotIgnoreForGson;
@Expose(serialize = false)
private Long shouldIgnoreForGson;
@JsonIgnore(false)
private Long shouldNotIgnoreForJackson;
@JsonIgnore
private Long shouldIgnoreForJackson;
//constructors...
//getters...
}| 名称 | 类型 | 是否必须 | 默认值 | 备注 | 其他信息 |
|---|---|---|---|---|---|
| shouldNotIgnoreForGson | integer | 非必须 | mock: @natural(0,10000) | ||
| shouldNotIgnoreForJackson | integer | 非必须 | mock: @natural(0,10000) |
# ignore field 'log'
field.ignore=logprivate String log;# ignore field 'log' typed xxx.xxx.Log
field.ignore=groovy:it.type().name()=="xxx.xxx.Log"private Log xxx;modifier的字段:#ignore transient field
field.ignore=groovy:it.hasModifier("transient")||it.hasModifier("protected")private transient Int xxx;
protected Long yyy;用于生成 apifox相关mock信息