作者:天佑忍者忍着 | 来源:互联网 | 2023-09-12 21:46
代码接入swagger后,运行成功,但get接口一直显示的参数在body,这并不符合
![](https://img5.php1.cn/3cdc5/9267/a6e/bb8e5a40a34988b8.png)
正常swagger会显得的get接口长这样:
![](https://img5.php1.cn/3cdc5/9267/a6e/37dbfda9284de96a.png)
尝试过好几次注解修改,终于试对了!
加入@ApiImplicitParams这个注解,就可以解决啦,里面的值根据自己的参数情况修改喔!
/*** 短信发送* phoneNumbers 待发送手机号* templateParam 模板中的变量替换JSON串,模板内容为"您的验证码为:${code},请勿泄露于他人!"*/@GetMapping(value = "/sendSms")@ApiOperation(value = "发送短信验证码")@ApiImplicitParams({@ApiImplicitParam(value = "電話號碼", name = "phoneNumbers",required = true,paramType = "query",dataType = "String"),@ApiImplicitParam(value = "短信模板編碼,0:登录,1:注册", name = "templateCode",required = true,paramType = "query",dataType = "String"),})public ResponseData sendSms(@RequestParam @NotBlank @Pattern(regexp = "^((13[0-9])|(14[0,1,4-9])|(15[0-3,5-9])|(16[2,5,6,7])|(17[0-8])|(18[0-9])|(19[0-3,5-9]))\\\\d{8}$")String phoneNumbers, @RequestParam @NotBlank String templateCode) {log.info("phoneNumbers:{},templateCode:{}",phoneNumbers,templateCode);