我有一个 Spring Boot 应用程序,它使用 swagger-ui 来公开它的 api。现在,直到我使用 springfox-swagger-ui 版本 2.6.1 为止,我的代码都可以正常工作。但是当我将版本更新到 2.7.0 时,它会抛出一个错误,指出 ApiInfo 方法已被弃用。谁能告诉我一个替代方案,它将尽可能少地修改现有代码并成功运行应用程序,并且信息仍然存在于 Swagger UI 中作为描述。我在这里给出了 swagger 配置的现有代码......
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.useDefaultResponseMessages(false)
.select()
.apis(RequestHandlerSelectors.basePackage("com.xyz.abc"))
.paths(regex("/api.*"))
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfo(
"My-Project Api",
"Api for My Project",
"V1",
"NA terms of service url",
new Contact("Team Name", "www.somexyzteamcontact.com, "NA"),
"A license given",
"NA");
}
}
Run Code Online (Sandbox Code Playgroud)
以及我在我的项目中使用的 swagger 的 gradle 依赖项:
compile group: 'io.springfox', name: …Run Code Online (Sandbox Code Playgroud)