swagger常用注解说明
1、@Api
用在类上,说明该类的作用。
@Api(tags = "BsFieldController",description = "Field相关接口")
2、@ApiOperation
用在方法上,说明方法的作用
@ApiOperation(value = "BsField条件分页查询",notes = "分页条件查询BsField方法详情",tags = {"BsFieldController"})
3、@ApiImplicitParams
用在方法上包含一组参数说明
4、@ApiImplicitParam
表示单独的请求参数
@ApiOperation(value = "BsField条件分页查询",notes = "分页条件查询BsField方法详情",tags = {"BsFieldController"}) @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", name = "page", value = "当前页", required = true, dataType = "Integer"), @ApiImplicitParam(paramType = "path", name = "size", value = "每页显示条数", required = true, dataType = "Integer") }) @PostMapping(value = "/search/{page}/{size}" ) public Result<List<BsField>> findPage(@RequestBody(required = false) @ApiParam(name = "BsField对象",value = "传入JSON数据",required = false) BsField bsField, @PathVariable int page, @PathVariable int size){ //调用BsFieldService实现分页条件查询BsField List<BsField> bsFieldList = bsFieldService.findPage(bsField, page, size); return new Result(StatusCode.OK,"查询成功",bsFieldList); }
5、@Apiparam
用于方法,参数,字段说明
/*** * 根据ID查询BsField数据 * @param id * @return */ @ApiOperation(value = "BsField根据ID查询",notes = "根据ID查询BsField方法详情",tags = {"BsFieldController"}) @GetMapping("/{id}") public Result<BsField> findById(@PathVariable @ApiParam(value = "主键ID", required = true) Integer id){ //调用BsFieldService实现根据主键查询BsField BsField bsField = bsFieldService.findById(id); return new Result<BsField>(StatusCode.OK,"查询成功",bsField); }