在我們的spring-webmvc專案中我們使用下面的代碼來配置swagger2,現在我們要升級到swagger3,所以我們在pom檔案中添加了springdoc-openapi-ui,我們需要在swagger-configuration檔案中做哪些修改
@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);
}
}
uj5u.com熱心網友回復:
你必須像這樣洗掉@EnableSwagger2
和改變你的Docket api()。
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI().info(new Info().title("SpringShop API"));}
有關更多詳細資訊,請參閱此檔案https://springdoc.org/#migrating-from-springfox。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/321969.html
