Skip to content

Commit 01810fc

Browse files
committed
feat: Swagger 연동(controller, dto)
1 parent ee6aea8 commit 01810fc

20 files changed

+80
-10
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java'
3-
id 'org.springframework.boot' version '3.4.2'
3+
id 'org.springframework.boot' version '3.3.6'
44
id 'io.spring.dependency-management' version '1.1.7'
55
}
66

src/main/java/com/weve/controller/AuthController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import com.weve.common.api.payload.code.status.ErrorStatus;
55
import com.weve.dto.request.UserRequestDto;
66
import com.weve.service.AuthService;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
78
import jakarta.persistence.Basic;
89
import lombok.RequiredArgsConstructor;
910
import org.springframework.web.bind.annotation.*;
1011

1112
@RestController
1213
@RequestMapping("/api/auth")
1314
@RequiredArgsConstructor
15+
@Tag(name = "Auth", description = "Auth 관련 API입니다.")
1416
public class AuthController {
1517

1618
private final AuthService authService;

src/main/java/com/weve/controller/GcsController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.weve.common.api.payload.BasicResponse;
44
import com.weve.dto.response.UploadFileResponse;
55
import com.weve.service.GcsService;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
68
import lombok.RequiredArgsConstructor;
79
import lombok.extern.slf4j.Slf4j;
810
import org.springframework.validation.annotation.Validated;
@@ -19,11 +21,13 @@
1921
@Validated
2022
@Slf4j
2123
@RequestMapping("/api/storage")
24+
@Tag(name = "Storage", description = "Goolge Cloud Storage 관련 API입니다.")
2225
public class GcsController {
2326

2427
private final GcsService gcsService;
2528

2629
@PostMapping("/upload")
30+
@Operation(summary = "파일 업로드", description = "파일을 업로드하여 URL을 생성합니다.")
2731
public BasicResponse<UploadFileResponse> uploadFile(@RequestPart(value = "file") MultipartFile multipartFile) throws IOException {
2832

2933

src/main/java/com/weve/controller/HealthCheckController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.weve.controller;
22

3+
import io.swagger.v3.oas.annotations.Hidden;
34
import org.springframework.http.ResponseEntity;
45
import org.springframework.web.bind.annotation.GetMapping;
56
import org.springframework.web.bind.annotation.RestController;
67

7-
// @Hidden (스웨거 숨김)
8+
@Hidden
89
@RestController
910
public class HealthCheckController {
1011

src/main/java/com/weve/controller/MessageController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.weve.common.api.payload.BasicResponse;
44
import com.weve.service.MessageService;
5+
import io.swagger.v3.oas.annotations.tags.Tag;
56
import jakarta.persistence.Basic;
67
import lombok.RequiredArgsConstructor;
78
import lombok.extern.slf4j.Slf4j;
@@ -14,6 +15,7 @@
1415
@Validated
1516
@Slf4j
1617
@RequestMapping("/api/auth/sms")
18+
@Tag(name = "SMS", description = "SMS 관련 API입니다.")
1719
public class MessageController {
1820

1921
private final MessageService messageService;

src/main/java/com/weve/controller/SttController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.weve.common.api.payload.BasicResponse;
44
import com.weve.dto.response.SpeechToTextResponse;
55
import com.weve.service.SttService;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
68
import lombok.RequiredArgsConstructor;
79
import lombok.extern.slf4j.Slf4j;
810
import org.springframework.http.MediaType;
@@ -20,14 +22,13 @@
2022
@Validated
2123
@Slf4j
2224
@RequestMapping("/api/stt")
25+
@Tag(name = "STT", description = "STT(Speech-to-Text) 관련 API입니다.")
2326
public class SttController {
2427

2528
private final SttService sttService;
2629

27-
/**
28-
* STT(Speech-to-Text) : 오디오 파일을 받아서 텍스트로 변환하여 반환
29-
*/
3030
@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
31+
@Operation(summary = "STT(Speech-to-Text)", description = "오디오 파일을 업로드하여 텍스트로 변환합니다.")
3132
public BasicResponse<SpeechToTextResponse> handleAudioMessage(@RequestParam MultipartFile audioFile,
3233
@RequestParam(defaultValue = "ios") String os) throws IOException {
3334
int frequency = os.equals("android") ? 44100 : 48000; //샘플링 주파수: ios-48000, android-44100

src/main/java/com/weve/controller/TtsController.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.weve.controller;
22

33
import com.weve.service.TtsService;
4+
import io.swagger.v3.oas.annotations.Operation;
5+
import io.swagger.v3.oas.annotations.tags.Tag;
46
import lombok.RequiredArgsConstructor;
57
import org.springframework.http.ResponseEntity;
68
import org.springframework.web.bind.annotation.GetMapping;
@@ -9,14 +11,18 @@
911
import org.springframework.web.bind.annotation.RestController;
1012

1113
@RestController
12-
@RequestMapping("/api/tts")
14+
@RequestMapping("/tts")
1315
@RequiredArgsConstructor
16+
@Tag(name = "TTS", description = "TTS(Text-to-Speech) 관련 API입니다.")
1417
public class TtsController {
1518

1619
private final TtsService ttsService;
1720

18-
// 테스트용
1921
@GetMapping
22+
@Operation(
23+
summary = "[API 연동 X] 텍스트를 음성 파일(URL)로 변환 (TTS)",
24+
description = "입력된 텍스트를 음성 파일로 변환하고, 해당 파일의 URL을 생성합니다.(고정 음성 파일을 Swagger에서 생성하는 용도)"
25+
)
2026
public ResponseEntity<byte[]> convertTextToSpeech(@RequestParam String text) throws Exception {
2127
byte[] audio = ttsService.convertTextToSpeech(text);
2228
return ResponseEntity.ok()

src/main/java/com/weve/controller/UserController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.weve.repository.UserRepository;
88
import com.weve.security.CustomUserDetails;
99
import com.weve.service.UserService;
10+
import io.swagger.v3.oas.annotations.tags.Tag;
1011
import jakarta.validation.Valid;
1112
import lombok.RequiredArgsConstructor;
1213
import lombok.extern.slf4j.Slf4j;
@@ -25,6 +26,7 @@
2526
@Validated
2627
@Slf4j
2728
@RequestMapping("/api/mypage")
29+
@Tag(name = "User", description = "User 관련 API입니다.")
2830
public class UserController {
2931

3032
private final UserService userService;

src/main/java/com/weve/controller/WorryController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.weve.dto.response.*;
77
import com.weve.service.AnswerService;
88
import com.weve.service.WorryService;
9+
import io.swagger.v3.oas.annotations.Operation;
10+
import io.swagger.v3.oas.annotations.tags.Tag;
911
import jakarta.validation.Valid;
1012
import lombok.RequiredArgsConstructor;
1113
import lombok.extern.slf4j.Slf4j;
@@ -19,6 +21,7 @@
1921
@Validated
2022
@Slf4j
2123
@RequestMapping("/api/worries")
24+
@Tag(name = "Worry", description = "Worry 관련 API입니다.")
2225
public class WorryController {
2326

2427
private final WorryService worryService;
@@ -28,6 +31,7 @@ public class WorryController {
2831
* 고민 작성하기
2932
*/
3033
@PostMapping
34+
@Operation(summary = "고민 작성하기", description = "고민을 작성합니다.")
3135
public BasicResponse<CreateWorryResponse> createWorry(@AuthenticationPrincipal UserDetails userDetails,
3236
@RequestBody @Valid CreateWorryRequest request) {
3337

@@ -41,6 +45,7 @@ public BasicResponse<CreateWorryResponse> createWorry(@AuthenticationPrincipal U
4145
* 고민 목록 조회(JUNIOR ver)
4246
*/
4347
@GetMapping("/junior")
48+
@Operation(summary = "고민 목록 조회(JUNIOR ver)", description = "고민 목록을 조회합니다.(JUNIOR ver)")
4449
public BasicResponse<GetWorriesResponse.JuniorVer> getWorriesForJunior(@AuthenticationPrincipal UserDetails userDetails) {
4550
String username = userDetails.getUsername();
4651
GetWorriesResponse.JuniorVer response = worryService.getWorriesForJunior(username);
@@ -51,6 +56,7 @@ public BasicResponse<GetWorriesResponse.JuniorVer> getWorriesForJunior(@Authenti
5156
* 고민 목록 조회(SENIOR ver)
5257
*/
5358
@GetMapping("/senior")
59+
@Operation(summary = "고민 목록 조회(SENIOR ver)", description = "고민 목록을 조회합니다.(SENIOR ver)")
5460
public BasicResponse<GetWorriesResponse.SeniorVer> getWorriesForSenior(@AuthenticationPrincipal UserDetails userDetails) {
5561
String username = userDetails.getUsername();
5662
GetWorriesResponse.SeniorVer response = worryService.getWorriesForSenior(username);
@@ -61,6 +67,7 @@ public BasicResponse<GetWorriesResponse.SeniorVer> getWorriesForSenior(@Authenti
6167
* 고민 상세 조회(JUNIOR ver)
6268
*/
6369
@GetMapping("/{worryId}/junior")
70+
@Operation(summary = "고민 상세 조회(JUNIOR ver)", description = "고민을 상세 조회합니다.(JUNIOR ver)")
6471
public BasicResponse<GetWorryResponse.JuniorVer> getWorryForJunior(@AuthenticationPrincipal UserDetails userDetails,
6572
@PathVariable Long worryId) {
6673
String username = userDetails.getUsername();
@@ -72,6 +79,7 @@ public BasicResponse<GetWorryResponse.JuniorVer> getWorryForJunior(@Authenticati
7279
* 고민 상세 조회(SENIOR ver)
7380
*/
7481
@GetMapping("/{worryId}/senior")
82+
@Operation(summary = "고민 상세 조회(SENIOR ver)", description = "고민을 상세 조회합니다.(SENIOR ver)")
7583
public BasicResponse<GetWorryResponse.SeniorVer> getWorryForSenior(@AuthenticationPrincipal UserDetails userDetails,
7684
@PathVariable Long worryId) {
7785
String username = userDetails.getUsername();
@@ -83,6 +91,7 @@ public BasicResponse<GetWorryResponse.SeniorVer> getWorryForSenior(@Authenticati
8391
* 답변 작성하기
8492
*/
8593
@PostMapping("/{worryId}/answer")
94+
@Operation(summary = "답변 작성하기", description = "답변을 작성합니다.")
8695
public BasicResponse<?> createAnswer(@AuthenticationPrincipal UserDetails userDetails,
8796
@PathVariable Long worryId,
8897
@RequestBody @Valid CreateAnswerRequest request) {
@@ -97,6 +106,7 @@ public BasicResponse<?> createAnswer(@AuthenticationPrincipal UserDetails userDe
97106
* 답변 상세 조회(JUNIOR ver)
98107
*/
99108
@GetMapping("/{worryId}/answer/junior")
109+
@Operation(summary = "답변 상세 조회(JUNIOR ver)", description = "답변을 상세 조회합니다.(JUNIOR ver)")
100110
public BasicResponse<GetAnswerResponse.JuniorVer> getAnswerForJunior(@AuthenticationPrincipal UserDetails userDetails,
101111
@PathVariable Long worryId) {
102112
String username = userDetails.getUsername();
@@ -108,6 +118,7 @@ public BasicResponse<GetAnswerResponse.JuniorVer> getAnswerForJunior(@Authentica
108118
* 답변 상세 조회(SENIOR ver)
109119
*/
110120
@GetMapping("/{worryId}/answer/senior")
121+
@Operation(summary = "답변 상세 조회(SENIOR ver)", description = "답변을 상세 조회합니다.(SENIOR ver)")
111122
public BasicResponse<GetAnswerResponse.SeniorVer> getAnswerForSenior(@AuthenticationPrincipal UserDetails userDetails,
112123
@PathVariable Long worryId) {
113124
String username = userDetails.getUsername();
@@ -119,6 +130,7 @@ public BasicResponse<GetAnswerResponse.SeniorVer> getAnswerForSenior(@Authentica
119130
* 감사편지 상세 조회(JUNIOR ver)
120131
*/
121132
@GetMapping("/{worryId}/appreciate/junior")
133+
@Operation(summary = "감사편지 상세 조회(JUNIOR ver)", description = "감사편지를 상세 조회합니다.(JUNIOR ver)")
122134
public BasicResponse<GetAppreciateResponse.JuniorVer> getAppreciateForJunior(@AuthenticationPrincipal UserDetails userDetails,
123135
@PathVariable Long worryId) {
124136
String username = userDetails.getUsername();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.weve.dto.request;
22

3+
import io.swagger.v3.oas.annotations.media.Schema;
34
import lombok.Builder;
45
import lombok.Getter;
56

67
@Getter
78
@Builder
89
public class CreateAnswerRequest {
910

11+
@Schema(description = "답변 내용", nullable = false, example = "힘내요 젊은이..")
1012
private String content;
13+
@Schema(description = "이미지 URL", nullable = true, example = "...")
1114
private String imageUrl;
1215
}

0 commit comments

Comments
 (0)