From 00f82c34b6feb341fd17b9969ccefcab46890923 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 26 Aug 2020 12:27:50 +0200 Subject: [PATCH] JAVA-2398: Fix Spring Boot 2 integration with Swagger 3.0.0 --- spring-boot-modules/spring-boot-mvc/pom.xml | 23 ++++--------------- .../configuration/SpringFoxConfig.java | 19 ++++++++------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/spring-boot-modules/spring-boot-mvc/pom.xml b/spring-boot-modules/spring-boot-mvc/pom.xml index 9ae6d8341a..39046ee6d9 100644 --- a/spring-boot-modules/spring-boot-mvc/pom.xml +++ b/spring-boot-modules/spring-boot-mvc/pom.xml @@ -49,6 +49,10 @@ org.springframework.boot spring-boot-starter-data-jpa + + org.springframework.boot + spring-boot-starter-data-rest + mysql @@ -99,24 +103,7 @@ io.springfox - springfox-swagger2 - ${spring.fox.version} - - - io.springfox - springfox-swagger-ui - ${spring.fox.version} - - - - io.springfox - springfox-data-rest - ${spring.fox.version} - - - - io.springfox - springfox-bean-validators + springfox-boot-starter ${spring.fox.version} diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java index 434a8d77cb..b404b0c2f8 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java @@ -1,13 +1,9 @@ package com.baeldung.swagger2boot.configuration; -import org.springframework.boot.autoconfigure.domain.EntityScan; +import com.baeldung.swagger2boot.plugin.EmailAnnotationPlugin; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; - -import com.baeldung.swagger2boot.plugin.EmailAnnotationPlugin; - import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; @@ -16,13 +12,16 @@ import springfox.documentation.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger.web.*; -import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; +import springfox.documentation.swagger.web.DocExpansion; +import springfox.documentation.swagger.web.ModelRendering; +import springfox.documentation.swagger.web.OperationsSorter; +import springfox.documentation.swagger.web.TagsSorter; +import springfox.documentation.swagger.web.UiConfiguration; +import springfox.documentation.swagger.web.UiConfigurationBuilder; import java.util.Collections; @Configuration -@EnableSwagger2WebMvc @Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class}) public class SpringFoxConfig { @@ -43,8 +42,8 @@ public class SpringFoxConfig { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) .build(); }