swagger2前台页面测试接口,参数类型为path时报错问题required field is not provided解决方法

解决方法如下:如果参数作为路径,则不用再使用注解来声明该参数,否则在swagger2-ui页面中进行测试,则会出现required field is not provided错误,一直测试不通

//不能再写这个参数的说明信息了,否则swagger接口调试会报错 required field is not provided
    //@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Integer", paramType = "path")
    @GetMapping("/{id}/getUser")
    public User getUserById(@PathVariable("id") int id){
        return userService.getById(id);
    }

异常的解决方法:java.lang.NumberFormatException: For input string: “”

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
    <exclusions>
        <exclusion>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-models</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-models</artifactId>
    <version>1.5.22</version>
</dependency>
©️2020 CSDN 皮肤主题: 黑客帝国 设计师:上身试试 返回首页