部署Spring启动应用程序时Swagger UI错误验证

Raj*_*Raj 1 java swagger spring-boot

由于验证,Swagger-ui.html在页面底部显示错误

`{"schemaValidationMessages":[{"level":"error","message":"Can't read from file https://www.example.com/v2/api-docs"}]}`
Run Code Online (Sandbox Code Playgroud)

我做了一些研究,并且知道我们需要关闭验证来消除错误.但是如何从春季启动应用程序中关闭它.或者有没有办法在Spring启动应用程序中编辑swagger-ui.html?

错误如图所示

A. *_*son 6

自Swagger 2.8.0以来,许多构造函数已被弃用.我认为最好使用相应的构建器来处理我们所有未定义的参数,如下所示:

@Bean
public UiConfiguration uiConfig()
{
    return UiConfigurationBuilder.builder() //
             .displayRequestDuration( true ) //
             .validatorUrl( StringUtils.EMPTY ) // Disable the validator to avoid "Error" at the bottom of the Swagger UI page
             .build();
}
Run Code Online (Sandbox Code Playgroud)

另请参阅有关null或空字符串验证器的帖子