zoukankan      html  css  js  c++  java
  • swagger请求参数在header中添加token

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

    参照配置然而没有作用

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

     @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使用时不用加此注解

  • 相关阅读:
    input file 多张图片上传 获取地址 ——fileReader
    15个常用的javaScript正则表达式
    sublime-emmet
    AMD-requireJS
    jQuery-lazyload参数
    easyui 查询条件form 数据遍历
    导出excel设置金额格式
    html5页面添加时间戳
    创建枚举
    定义实体转json需要方法
  • 原文地址:https://www.cnblogs.com/h-c-g/p/11004105.html
Copyright © 2011-2022 走看看