網友大部分說的是如下配置
參照配置然而沒有作用
注掉改紅框內的配置,在方法上加如下注釋就可以用
@ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token標記", required = true) })
效果如圖
入參效果想有下圖示例
在入參實體類配置一下即可
@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使用時不用加此注解