描述类、方法和对象的作用

2021-05-20 SpringBootSwagger

# @Api:描述类的作用,用在Controller类上

  1. value="描述信息"
  2. description="详细描述该类的作用"

# @ApiOperation:用在Controller请求方法上,描述方法的作用

@ApiOperation("获取有多少个关卡")
public Integer getCheckNum() {
    return 1;
}

# @ApiModel:用在请求参数是对象上,描述该对象类的作用

@ApiModel(value="CategoryREQ对象", description="类别查询条件")
public class CategoryREQ extends BaseRequest<Category> {}

# @ApiModelProperty:用在请求参数是对象的属性上,描述对象属性的作用。

  1. value:属性的描述
  2. hidden:是否是查询条件属性, false:(默认值)在api文档显示,作为查询条件;true 隐藏,不是条件属性
public class Guest implements Serializable {

    @ApiModelProperty(value = "密码")
    private String password;
}
上次更新: 2 年前