From 6f2a82318eca11935e9b1a60a0df1e88462c2df5 Mon Sep 17 00:00:00 2001 From: jeongju Date: Sun, 1 Dec 2024 17:29:47 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20swagger=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 +++ .../innerjoin/config/SwaggerConfig.java | 26 +++++++++++++++++++ src/main/resources/application.yml | 7 +++++ 3 files changed, 36 insertions(+) create mode 100644 src/main/java/com/likelion/innerjoin/config/SwaggerConfig.java diff --git a/build.gradle b/build.gradle index 0faa5d4..842d5f8 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,9 @@ dependencies { runtimeOnly 'com.mysql:mysql-connector-j' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + //swagger + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' } tasks.named('test') { diff --git a/src/main/java/com/likelion/innerjoin/config/SwaggerConfig.java b/src/main/java/com/likelion/innerjoin/config/SwaggerConfig.java new file mode 100644 index 0000000..4ca904f --- /dev/null +++ b/src/main/java/com/likelion/innerjoin/config/SwaggerConfig.java @@ -0,0 +1,26 @@ +package com.likelion.innerjoin.config; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import lombok.RequiredArgsConstructor; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@OpenAPIDefinition( + info = @Info(title = "Zerock App", version = "v1")) +@RequiredArgsConstructor +@Configuration +public class SwaggerConfig { + + @Bean + public GroupedOpenApi chatOpenApi(){ + String[] paths = {"/**"}; + + return GroupedOpenApi.builder() + .group("Zerock OPEN API v1") + .pathsToMatch(paths) + .build(); + } + +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e79416b..98dae6d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -20,3 +20,10 @@ server: servlet: session: timeout: 30m + +springdoc: + api-docs: + enabled: true + swagger-ui: + enabled: true +