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

  • 相关阅读:
    MySQL Unable to convert MySQL datetime value to System.DateTime 解决方案
    Zend 无限试用
    SQL 触发器
    C# 多线程示例
    JS 实现打印
    apache开启.htaccess
    MySQL 安装包下载教程
    js系列(10)js的运用(二)
    js系列(9)js的运用(一)
    js系列(8)简介
  • 原文地址:https://www.cnblogs.com/h-c-g/p/11004105.html
Copyright © 2011-2022 走看看