JAVA-2398: Fix Spring Boot 2 integration with Swagger 3.0.0

This commit is contained in:
Krzysztof Woyke 2020-08-26 12:27:50 +02:00
parent 9d27ebbc80
commit 00f82c34b6
2 changed files with 14 additions and 28 deletions

View File

@ -49,6 +49,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
@ -99,24 +103,7 @@
<!-- Spring Fox 2 --> <!-- Spring Fox 2 -->
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-boot-starter</artifactId>
<version>${spring.fox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${spring.fox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>${spring.fox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${spring.fox.version}</version> <version>${spring.fox.version}</version>
</dependency> </dependency>

View File

@ -1,13 +1,9 @@
package com.baeldung.swagger2boot.configuration; 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.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import com.baeldung.swagger2boot.plugin.EmailAnnotationPlugin;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
@ -16,13 +12,16 @@ import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration; import springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger.web.*; import springfox.documentation.swagger.web.DocExpansion;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; 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; import java.util.Collections;
@Configuration @Configuration
@EnableSwagger2WebMvc
@Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class}) @Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class})
public class SpringFoxConfig { public class SpringFoxConfig {
@ -43,8 +42,8 @@ public class SpringFoxConfig {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo()) .apiInfo(apiInfo())
.select() .select()
.apis(RequestHandlerSelectors.any()) .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build(); .build();
} }