Skip to content

Commit

Permalink
[ADD] 응답 클래스 타입 추가, 스웨거 설명 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Mar 20, 2024
1 parent b783dae commit 4ec6226
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 36 deletions.
101 changes: 84 additions & 17 deletions smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.smeem.api.diary.api;

import com.smeem.api.common.dto.FailureResponse;
import com.smeem.api.common.dto.SuccessResponse;
import com.smeem.api.diary.api.dto.request.DiaryCreateRequest;
import com.smeem.api.diary.api.dto.request.DiaryModifyRequest;
import com.smeem.api.diary.api.dto.response.DiaryCreateResponse;
import com.smeem.api.diary.api.dto.response.DiaryGetResponse;
import com.smeem.api.diary.api.dto.response.DiaryListGetResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -26,51 +30,114 @@ public interface DiaryApi {
@Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"),
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 토큰",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> createDiary(Principal principal, @RequestBody DiaryCreateRequest request);
ResponseEntity<SuccessResponse<DiaryCreateResponse>> createDiary(
Principal principal,
@RequestBody DiaryCreateRequest request
);

@Operation(summary = "일기 상세 조회 API")
@Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청", content = @Content),
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content)
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 토큰",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<DiaryGetResponse>> getDiaryDetail(@PathVariable long diaryId);

@Operation(summary = "일기 수정 API")
@Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"),
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 토큰",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> modifyDiary(@PathVariable long diaryId, @RequestBody DiaryModifyRequest request);

@Operation(summary = "일기 삭제 API")
@Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"),
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 토큰",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> deleteDiary(@PathVariable long diaryId);

@Operation(summary = "기간 내 일기 목록 조회 API")
@Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"),
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 토큰",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> getDiaries(
ResponseEntity<SuccessResponse<DiaryListGetResponse>> getDiaries(
Principal principal,
@RequestParam String start,
@RequestParam String end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DiaryApiController implements DiaryApi {
private final DiaryQueryService diaryQueryService;

@PostMapping
public ResponseEntity<SuccessResponse<?>> createDiary(Principal principal, @RequestBody DiaryCreateRequest request) {
public ResponseEntity<SuccessResponse<DiaryCreateResponse>> createDiary(Principal principal, @RequestBody DiaryCreateRequest request) {
val memberId = Util.getMemberId(principal);
val response = DiaryCreateResponse.from(
diaryCommandService.createDiary(DiaryCreateServiceRequest.of(memberId, request)));
Expand All @@ -51,7 +51,7 @@ public ResponseEntity<SuccessResponse<?>> createDiary(Principal principal, @Requ
public ResponseEntity<SuccessResponse<DiaryGetResponse>> getDiaryDetail(@PathVariable long diaryId) {
val response = DiaryGetResponse.from(
diaryQueryService.getDiaryDetail(DiaryGetServiceRequest.of(diaryId)));
return ApiResponseUtil.successTest(SUCCESS_GET_DIARY, response);
return ApiResponseUtil.success(SUCCESS_GET_DIARY, response);
}

@PatchMapping("/{diaryId}")
Expand All @@ -67,7 +67,7 @@ public ResponseEntity<SuccessResponse<?>> deleteDiary(@PathVariable long diaryId
}

@GetMapping
public ResponseEntity<SuccessResponse<?>> getDiaries(
public ResponseEntity<SuccessResponse<DiaryListGetResponse>> getDiaries(
Principal principal,
@RequestParam String start,
@RequestParam String end
Expand Down
33 changes: 27 additions & 6 deletions smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.smeem.api.goal.api;

import com.smeem.api.common.dto.FailureResponse;
import com.smeem.api.common.dto.SuccessResponse;
import com.smeem.api.goal.api.dto.response.GoalGetResponse;
import com.smeem.api.goal.api.dto.response.GoalListGetResponse;
import com.smeem.domain.goal.model.GoalType;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -15,16 +20,32 @@ public interface GoalApi {
@Operation(summary = "목표 전체 목록 조회 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> getAllGoals();
ResponseEntity<SuccessResponse<GoalListGetResponse>> getAllGoals();

@Operation(summary = "목표 상세 조회 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> getGoalByType(@PathVariable GoalType type);
ResponseEntity<SuccessResponse<GoalGetResponse>> getGoalByType(@PathVariable GoalType type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public class GoalApiController implements GoalApi {
private final GoalService goalService;

@GetMapping
public ResponseEntity<SuccessResponse<?>> getAllGoals() {
public ResponseEntity<SuccessResponse<GoalListGetResponse>> getAllGoals() {
val response = GoalListGetResponse.from(goalService.getAllGoals());
return ApiResponseUtil.success(SUCCESS_GET_GOALS, response);
}

@GetMapping("/{type}")
public ResponseEntity<SuccessResponse<?>> getGoalByType(@PathVariable GoalType type) {
public ResponseEntity<SuccessResponse<GoalGetResponse>> getGoalByType(@PathVariable GoalType type) {
val response = GoalGetResponse.from(goalService.getByType(GoalGetServiceRequest.of(type)));
return ApiResponseUtil.success(SUCCESS_GET_GOAL, response);
}
Expand Down
24 changes: 20 additions & 4 deletions smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.smeem.api.topic.api;

import com.smeem.api.common.dto.FailureResponse;
import com.smeem.api.common.dto.SuccessResponse;
import com.smeem.api.topic.api.dto.response.RandomTopicGetResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -17,9 +21,21 @@ public interface TopicApi {
@Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"),
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "4xx",
description = "유효하지 않은 요청",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 토큰",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> getTopicByRandom();
ResponseEntity<SuccessResponse<RandomTopicGetResponse>> getTopicByRandom();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TopicApiController implements TopicApi {
private final TopicService topicService;

@GetMapping("/random")
public ResponseEntity<SuccessResponse<?>> getTopicByRandom() {
public ResponseEntity<SuccessResponse<RandomTopicGetResponse>> getTopicByRandom() {
val response = RandomTopicGetResponse.from(topicService.getTopicByRandom());
return ApiResponseUtil.success(SUCCESS_GET_RANDOM_TOPIC, response);
}
Expand Down
12 changes: 10 additions & 2 deletions smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.smeem.api.version.api;

import com.smeem.api.common.dto.FailureResponse;
import com.smeem.api.common.dto.SuccessResponse;
import com.smeem.api.version.api.dto.response.ClientVersionGetResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -13,7 +17,11 @@ public interface VersionApi {
@Operation(summary = "클라이언트 앱 버전 조회 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = FailureResponse.class))
)
})
ResponseEntity<SuccessResponse<?>> getClientVersion();
ResponseEntity<SuccessResponse<ClientVersionGetResponse>> getClientVersion();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class VersionApiController implements VersionApi {
private final VersionService versionService;

@GetMapping("/client/app")
public ResponseEntity<SuccessResponse<?>> getClientVersion() {
public ResponseEntity<SuccessResponse<ClientVersionGetResponse>> getClientVersion() {
val response = ClientVersionGetResponse.of(versionService.getClientVersion());
return ApiResponseUtil.success(SUCCESS_GET_APP_VERSION, response);
}
Expand Down

0 comments on commit 4ec6226

Please sign in to comment.