From 721d7a92ff187f3eef88be5d8b695c1ded8d633c Mon Sep 17 00:00:00 2001 From: Dae-Hwa Date: Fri, 26 Nov 2021 13:55:51 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20SwaggerConfig=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=9B=84=20=EA=B4=80=EB=A0=A8=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/postsquad/scoup/ScoupApplication.java | 28 ----------- .../scoup/web/config/SwaggerConfig.java | 49 +++++++++++++++++++ .../postsquad/scoup/web/config/WebConfig.java | 12 ----- 3 files changed, 49 insertions(+), 40 deletions(-) create mode 100644 src/main/java/com/postsquad/scoup/web/config/SwaggerConfig.java diff --git a/src/main/java/com/postsquad/scoup/ScoupApplication.java b/src/main/java/com/postsquad/scoup/ScoupApplication.java index 665740d8..740fccca 100644 --- a/src/main/java/com/postsquad/scoup/ScoupApplication.java +++ b/src/main/java/com/postsquad/scoup/ScoupApplication.java @@ -1,18 +1,9 @@ package com.postsquad.scoup; -import com.google.common.base.Predicates; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; -@EnableSwagger2 @EnableJpaAuditing @SpringBootApplication public class ScoupApplication { @@ -20,23 +11,4 @@ public class ScoupApplication { public static void main(String[] args) { SpringApplication.run(ScoupApplication.class, args); } - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .groupName("Scoup") - .apiInfo(apiInfo()) - .select() - .paths(Predicates.not(PathSelectors.regex("/error"))) - .paths(PathSelectors.ant("/**")) - .build(); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("Scoup API Documentation") - .version("1.0") - .description("Scoup의 API 문서입니다.") - .build(); - } } diff --git a/src/main/java/com/postsquad/scoup/web/config/SwaggerConfig.java b/src/main/java/com/postsquad/scoup/web/config/SwaggerConfig.java new file mode 100644 index 00000000..4682aff6 --- /dev/null +++ b/src/main/java/com/postsquad/scoup/web/config/SwaggerConfig.java @@ -0,0 +1,49 @@ +package com.postsquad.scoup.web.config; + +import com.google.common.base.Predicates; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.hateoas.client.LinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverers; +import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer; +import org.springframework.plugin.core.SimplePluginRegistry; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.List; + +@EnableSwagger2 +@Configuration +public class SwaggerConfig { + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .groupName("Scoup") + .apiInfo(apiInfo()) + .select() + .paths(Predicates.not(PathSelectors.regex("/error"))) + .paths(PathSelectors.ant("/**")) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("Scoup API Documentation") + .version("1.0") + .description("Scoup의 API 문서입니다.") + .build(); + } + + @Bean + public LinkDiscoverers discoverers() { + List plugins = new ArrayList<>(); + plugins.add(new CollectionJsonLinkDiscoverer()); + return new LinkDiscoverers(SimplePluginRegistry.create(plugins)); + } +} diff --git a/src/main/java/com/postsquad/scoup/web/config/WebConfig.java b/src/main/java/com/postsquad/scoup/web/config/WebConfig.java index f9723a7c..7819b28b 100644 --- a/src/main/java/com/postsquad/scoup/web/config/WebConfig.java +++ b/src/main/java/com/postsquad/scoup/web/config/WebConfig.java @@ -7,12 +7,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.hateoas.client.LinkDiscoverer; -import org.springframework.hateoas.client.LinkDiscoverers; -import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer; import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.plugin.core.SimplePluginRegistry; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.reactive.function.client.ExchangeStrategies; import org.springframework.web.reactive.function.client.WebClient; @@ -21,7 +17,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import reactor.netty.http.client.HttpClient; -import java.util.ArrayList; import java.util.List; @RequiredArgsConstructor @@ -76,11 +71,4 @@ public void addInterceptors(InterceptorRegistry registry) { .addPathPatterns("/**") .excludePathPatterns(SIGNIN_PATH_TO_EXCLUDE); } - - @Bean - public LinkDiscoverers discoverers() { - List plugins = new ArrayList<>(); - plugins.add(new CollectionJsonLinkDiscoverer()); - return new LinkDiscoverers(SimplePluginRegistry.create(plugins)); - } }