From 2b2a4e4dc20113cf316a1aed202d1e9de228dea7 Mon Sep 17 00:00:00 2001 From: jeongeungyeong Date: Wed, 2 Oct 2024 07:19:19 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20swagger=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=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 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 080c8ab..062e32f 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,8 @@ dependencies { implementation 'io.jsonwebtoken:jjwt:0.9.1' // 자바 JWT 라이브러리 implementation 'javax.xml.bind:jaxb-api:2.3.1' // XML 문서와 Java 객체 간 매핑 자동화 testAnnotationProcessor('org.projectlombok:lombok') - + //swagger + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' // Jackson implementation 'com.fasterxml.jackson.core:jackson-databind' // Spring Batch From bd80232c97cc1d053270e088a4fbf488919da75e Mon Sep 17 00:00:00 2001 From: jeongeungyeong Date: Wed, 2 Oct 2024 07:19:41 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20swaggerConfig=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ribbon/global/config/SwaggerConfig.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/wanted/ribbon/global/config/SwaggerConfig.java diff --git a/src/main/java/wanted/ribbon/global/config/SwaggerConfig.java b/src/main/java/wanted/ribbon/global/config/SwaggerConfig.java new file mode 100644 index 0000000..67658b7 --- /dev/null +++ b/src/main/java/wanted/ribbon/global/config/SwaggerConfig.java @@ -0,0 +1,27 @@ +package wanted.ribbon.global.config; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfig { + @Bean + public GroupedOpenApi publicApi() { + return GroupedOpenApi.builder() //경로 설정 + .group("springdoc-public") + .pathsToMatch("/**") + .build(); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("Yellow-Ribbon API") + .version("v2") + .description("옐로리본 운영서버 API 명세서")); + } +} From e283876c7491d03f94b70713d282501d5ec88eb8 Mon Sep 17 00:00:00 2001 From: jeongeungyeong Date: Wed, 2 Oct 2024 07:20:28 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20Security=EA=B4=80=EB=A0=A8=20swagge?= =?UTF-8?q?r=20=EC=84=A4=EC=A0=95=20=EB=AA=A8=EB=93=A0=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=20=ED=97=88=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/wanted/ribbon/user/config/WebSecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/wanted/ribbon/user/config/WebSecurityConfig.java b/src/main/java/wanted/ribbon/user/config/WebSecurityConfig.java index 36dbc39..0e93c30 100644 --- a/src/main/java/wanted/ribbon/user/config/WebSecurityConfig.java +++ b/src/main/java/wanted/ribbon/user/config/WebSecurityConfig.java @@ -27,6 +27,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .authorizeRequests(auth -> auth .requestMatchers("/api/users/login", "/api/users/signup").permitAll() .requestMatchers("/api/datapipes/**").permitAll() // 데이터파이프라인 모든 권한 허용 + .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-resources/**").permitAll() //swagger .anyRequest().authenticated()) .formLogin(AbstractHttpConfigurer::disable) .addFilterBefore(new TokenAuthenticationFilter(tokenProvider), UsernamePasswordAuthenticationFilter.class); From 7de58b2367383ed158f268d411b8d17450677c78 Mon Sep 17 00:00:00 2001 From: jeongeungyeong Date: Wed, 2 Oct 2024 07:21:07 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20swagger=20Tag,=20Operation=20?= =?UTF-8?q?=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ribbon/datapipe/controller/OpenApiController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/wanted/ribbon/datapipe/controller/OpenApiController.java b/src/main/java/wanted/ribbon/datapipe/controller/OpenApiController.java index c13a33b..9140070 100644 --- a/src/main/java/wanted/ribbon/datapipe/controller/OpenApiController.java +++ b/src/main/java/wanted/ribbon/datapipe/controller/OpenApiController.java @@ -1,6 +1,8 @@ package wanted.ribbon.datapipe.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -12,24 +14,28 @@ @RestController @RequestMapping("/api/datapipes") @RequiredArgsConstructor +@Tag(name="DataPipe",description = "경기도 공공데이터 수집 관련 API입니다.") public class OpenApiController { private final GenrestrtService genrestrtService; private final RawDataService rawDataService; // 경기도 맛집 데이터 수집 API (RestTemplate), responsebody 사용으로 PostMapping으로 진행 @PostMapping("/fetch-data") + @Operation(summary = "경기도 맛집 수집", description = "경기도 맛집 데이터를 restTemplate 방식으로 가져옵니다. " + + "김밥, 중국식, 일식 등 일부 카테고리만 가져올 수 있습니다.") public ResponseEntity fetchData(@RequestParam("serviceName") String serviceName) { // openAPI 호출 genrestrtService.fetchAndSaveData(serviceName); return ResponseEntity.ok(serviceName + "가 db에 성공적으로 저장됐습니다."); } - // 경기도 맛집 데이터 수집 API (WebClient, 모든 경기도 맛집 api 가능) /** * 데이터 조회로 GetMapping 사용 * 비동기 처리를 위한 Mono 사용 */ @GetMapping("/fetch-and-save") + @Operation(summary = "경기도 맛집 수집", description = "경기도 맛집 데이터를 webClient 방식으로 가져옵니다. " + + "경기도 맛집의 모든 음식점 카테고리를 가져올 수 있습니다.") public Mono> fetchAndSaveData(@RequestParam("serviceName") String serviceName) { return rawDataService.getAndSaveByServiceName(serviceName) .map(ResponseEntity::ok)