swagger use of collection

1. Open the swagger-ui background error java.lang.NumberFormatException: For input string: ""

The reason given is that io.springfox pom introduced: springfox-swagger-ui: 2.92 version of the jar package built for the io.swagger: swagger-models packages for version 1.5.20. 1.5.20 version of the judgment in the case of example only determine whether the null, there is no judgment example is an empty string "" So error. 1.5.21 version adds determine whether the example is null and "", so rule out re-import package 1.5.20 1.5.21 package to solve the
solution:

<!-- swagger2-UI-->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
    <exclusions>
        <exclusion>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-models</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- io.springfox:springfox-swagger2:2.9.2中依赖了swagger-models的1.5.20版本,通过排除springfox-swagger2中的swagger-models依赖,
导入io.swagger:swagger-models的1.5.21版本.解决io.swagger.models.parameters.AbstractSerializableParameter实例化参数时example为
空字符串""而报错的问题.因为1.5.20的example只判断是否为null,1.5.21判断了是否为null和""-->
<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-models</artifactId>
    <version>1.5.21</version>
</dependency>

Reference: https: //blog.csdn.net/bad_yixiong/article/details/96343823

2. swagger not pass parameters (given is java.lang.IllegalStateException:)

This happens, modify paramType = "query", or as a header, or do not write this property
, for example:

@ApiImplicitParams({
        @ApiImplicitParam(paramType="query", name = "loginname", value = "手机号码", required = true, dataType = "String"),
        @ApiImplicitParam(paramType = "query", name = "password", value = "密码", required = true, dataType = "String"),
        @ApiImplicitParam(paramType = "query", name = "classifyVersionCode", value = "客户端分类版本号", required = true, dataType = "Integer"),
        @ApiImplicitParam(paramType = "query", name = "ap    pVersionCode", value = "客户端apk版本号", required = true, dataType = "Integer"),
        @ApiImplicitParam(paramType = "query", name = "userType", value = "客户端类型", required = true, dataType = "Integer")
    })
@ApiImplicitParam(value = "主题站的类别id",name = "id",required = true,dataType = "int",defaultValue = "7")

Reference: https: //blog.csdn.net/qq_20516587/article/details/81109842

Published 19 original articles · won praise 4 · Views 1562

Guess you like

Origin blog.csdn.net/DATANGguanjunhou/article/details/102733213