When trying to upgrade my spring boot project from 2.5.6 to 3.2.5 swagger UI stops working. In version 2.5.6, I do not have spring security nor security config. I have only SwaggerConfig :
@Configuration
public class SwaggerConfig {
@Value("${spring.application.name}")
private String applicationId;
@Value("${spring.application.description}")
private String description;
@Value("${spring.application.version}")
private String version;
@Value("${app.env}")
private String env;
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(apiInfo())
.components(new Components());
}
private Info apiInfo(){
Info info= new Info();
info.setTitle(env + " - " + applicationId);
info.setDescription(description);
info.version(version);
return info;
}
}
Is it necessary to add spring security after upgrading to spring boot 3.2.5, or should i change my SwaggerConfig? Or is the problem somewhere else?
Thank you very much and have a good day.
It seems like the compatibility issue in your case might be due to SpringFox not being updated since July 2020, and its latest version, 3.0.0, only supports Spring Boot 2.0.0.
You might need to switch to SpringDoc, which is compatible with Spring Boot 3.0.0 and onwards.
This migration guide will be a great help to you
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.2.0'
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.2.0</version>
</dependency>
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(new Info()
.title("Title of the API")
.description("Description of the API.")
.version("Version of the API"));
}
}
have a nice day - kevin