In our spring-webmvc project we are using the following code to configure swagger2, now we want to upgrade to swagger3, so we added springdoc-openapi-ui in pom file, what changes we need to make in our swagger-configuration file
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.hjk.controller"))
.paths(PathSelectors.any())
.build()
.apiInfo(getApiInfo());
}
private ApiInfo getApiInfo() {
return new ApiInfo(title, description, version, termsOfServiceUrl, contact, license, licenseUrl);
}
}
CodePudding user response:
You have to remove @EnableSwagger2
and change your Docket api()
like this.
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI().info(new Info().title("SpringShop API"));}
For more details Please refer to this docs https://springdoc.org/#migrating-from-springfox.