I am learning how to use Swagger 3 in Spring Boot 3.25. I can access http://localhost:8080/rad
and test data is available.
My dependencies
<dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
My application
@SpringBootApplication
@EnableOpenApi
public class appserver3 {
public static void main(String[] args) {
SpringApplication.run(appserver3.class,args);
}
}
My config
@Configuration
public class swagger_config {
@Bean
public Docket apiconfig(){
return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title("Fingers")
.description("fingers")
.contact(new Contact("1", "2", "3"))
.version("1.0")
.build();
}
}
my application.yml
Spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
How do I solve this?
As you mentioned you're using Swagger 3 which is basically OpenApi 3.0 so you have to modify your swagger_config class because you're using Swagger 2.0 config which is not compatible with Swagger 3.
Docket and ApiInfo is not supporting any more in Swagger 3.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-data-rest</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>2.5.0</version>
</dependency>
You can refer these links for more details