网上解决方法:在swagger-ui/index.html中加js配置(因为我们直接用的是jar里面的swagger-ui.html,所以无法修改,pass)
Swagger-UI默认会将你的接口JSON传给swagger.io进行格式验证,然后对于我们已经使用了swagger的项目来说基本不需要(因为写错了Annotation的话会造成Swagger JSON接口报错),而且内部项目有时也不方便暴露,所以我们可以关闭验证功能来去除右下角的ERROR提示图标。这个配置并不存在于swagger-ui/index.html中,我们需要手动在Swagger UI声明时设置一个新参数:
// ...
window.swaggerUi = new SwaggerUi({ // ...
validatorUrl: null, //添加这个配置
});// ...
我们的解决方法:升级swagger版本
在pom.xml中加入Swagger2的依赖
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
注意:如果是2.2版本的,有可能在右下角会出现错误,那么请升级为2.7版本的即可解决这个问题。