网友大部分说的是如下配置

swagger请求参数在header中添加token

参照配置然而没有作用

注掉改红框内的配置,在方法上加如下注释就可以用

 @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true) })

swagger请求参数在header中添加token

效果如图

 

 

入参效果想有下图示例

swagger请求参数在header中添加token

在入参实体类配置一下即可

@Data
@ApiModel(value = "signIn",description = "账户")
public class SignIn {

    @ApiModelProperty(name = "id",dataType = "String",example = "1")
    private String id;
    @ApiModelProperty(name = "userName",dataType = "String",example = "San")
    private String userName;
    @ApiModelProperty(name = "userName",dataType = "String",example = "123456")
    private String password;


}

不是实体类的入参,还是使用

@ApiImplicitParams({ @ApiImplicitParam-------嵌套在方法上
@ApiImplicitParams({
        @ApiImplicitParam(paramType="header",name="username",dataType="String",required=true,value="用户的姓名",defaultValue="zhaojigang"),
        @ApiImplicitParam(paramType="query",name="password",dataType="String",required=true,value="用户的密码",defaultValue="wangna")
    })

 当然在postman使用时不用加此注解

swagger请求参数在header中添加token

 

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2021-11-01
  • 2021-07-20
  • 2021-11-07
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-12
  • 2021-07-05
  • 2022-01-08
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案