swagger中注释

swagger中接口注释Get请求

两种方式:

方式一:

这里注意需要加上一个dataType指明参数类型不然swagger就会默认为string类型

  @GetMapping("/app-anon/station")
    @ApiOperation(value = "下拉列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "选者下拉:1-所属分台下拉 2-任务Ip下拉", required = true),
            @ApiImplicitParam(name = "port", value = "是否app:true(是),其他就不是",dataType = "Boolean"),
    })
    public Result<List<PublicVO>> getAppList(@NotNull @RequestParam("type") String type,@RequestParam(value = "port",required = false)Boolean port) {
        return new Result<>(bksStationMaterialService.getAppList(type,port));
    }

方式二

@GetMapping("/app-anon/station")
@ApiOperation(value = "下拉列表")
public Result<List<PublicVO>> getAppList(@NotNull  @ApiParam("选者下拉:1-所属分台下拉 2-任务Ip下拉") @RequestParam(required = true) String type,
                                         @ApiParam("是否app:true(是),其他就不是")@RequestParam(required = false)Boolean port) {
    return new Result<>(bksStationMaterialService.getAppList(type,port));
}

注意这里是用@RequestParam前端就必须拼接到接口上,因为swagger会校验参数,所以不想让前端传参的时候就不能加这个注解,但是需要注解表示这个字段名称可以加@ApiImplicitParam这个注解

 @GetMapping("/list")
    @ApiOperation(value = "关注企业的列表")
    @ApiImplicitParam(name = "companyName", value = "企业名称")
    public Result<PageVO<FollowCompanyVO>> listCompany(PageInfo info, String companyName) {
        return new Result<>(memberCompanyService.listCompany(info, companyName));
    }

在这里插入图片描述

在这里插入图片描述

swagger注解

实体类中的注解使用@Valid 或者@Validated
在这里插入图片描述
在实体类中使用 @NotBlank注解标注不能为空,这里需要注意引入的包如下图
在这里插入图片描述

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱上编程2705

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值