springboot整合swagger2

本文档记录了SpringBoot项目中使用Swagger2进行接口文档化的详细步骤,包括接口描述、实体类参数、文件上传、单独参数处理、请求与返回body的注解使用,以及实体类的特别注意事项。特别提醒,@ApiModel的value值不应重复,否则会导致类合并。
摘要由CSDN通过智能技术生成

记录swagger使用-version2.9

注解描述参考(版本可能不一致):

https://blog.csdn.net/Jack_EUSong/article/details/80349694

https://blog.csdn.net/u014231523/article/details/76522486

接口使用(接受实体类参数)

@Api(value = “当前类的描述”) //作用于类上

@ApiOperation(value = “当前方法名”,notes = “当前方法的描述”)

@ApiResponses(当前返回类中有code参数,描述code参数, response = void.class)

@Valid (spring mvc注解,做校验用,需配合参数中 BindingResult )


    @PostMapping("/category_page_search")
    @ApiOperation(value = "根据分类查询并分页",notes = "根据分类ID查询商品并分页")
    @ApiResponses({
            @ApiResponse(code = 500, message = "内部错误"),
            @ApiResponse(code = 400, message = "参数错误"),
            @ApiResponse(code = 204, message = "没有返回结果"),
            @ApiResponse(code = 200, message = "成功", response = ApiResult.class)
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cid",value = "分类ID",required = true,dataType = "int"),
            @ApiImplicitParam(name = "page",value = "当前页",required = true,dataType = "int"),
            @ApiImplicitParam(name = "limit",value = "每页最大数",required = true,dataType = "int"),
            @ApiImplicitParam(name =
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值