控制器中的某个方法:
@GetMapping(value = "page")
@ApiOperation(value = "分页查询登录日志")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "分页参数:当前页", defaultValue = "1", required = false),
@ApiImplicitParam(name = "limit", value = "分页参数:每页数量", defaultValue = "10", required = false),
@ApiImplicitParam(name = "loginname", value = "登录名称", required = false),
@ApiImplicitParam(name = "loginip", value = "IP", required = false),
@ApiImplicitParam(name = "startTime", value = "登录起始时间", required = false),
@ApiImplicitParam(name = "endTime", value = "登录终止时间", required = false)
})
public Result page(LogVo vo) {
return null;
}
没有使用 @ApiIgnore 注解之前,在接口文档中存在一些不期望出现的请求参数:
为了隐藏这些不期望出现的请求参数,可以在方法的参数上使用 @ApiIgnore 注解,见以下代码块中的第 11 行:
@GetMapping(value = "page")
@ApiOperation(value = "分页查询登录日志")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "分页参数:当前页", defaultValue = "1", required = false),
@ApiImplicitParam(name = "limit", value = "分页参数:每页数量", defaultValue = "10", required = false),
@ApiImplicitParam(name = "loginname", value = "登录名称", required = false),
@ApiImplicitParam(name = "loginip", value = "IP", required = false),
@ApiImplicitParam(name = "startTime", value = "登录起始时间", required = false),
@ApiImplicitParam(name = "endTime", value = "登录终止时间", required = false)
})
public Result page(@ApiIgnore LogVo vo) {
return null;
}
注意:如果使用 @ApiIgnore 注解,但却没有使用 @ApiImplicitParam 注解隐式地声明接口参数,如下:
@GetMapping(value = "page")
@ApiOperation(value = "分页查询登录日志")
public Result page(@ApiIgnore LogVo vo) {
return null;
}