Skip to content

Commit

Permalink
[REFACTOR] 스웨거 응답 클래스 타입 명시
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Mar 17, 2024
1 parent bae3712 commit bc023ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ public record BaseResponse<T>(
) {

public static <T> BaseResponse<T> of(String message, T data) {
return new BaseResponse<>(true, message, data);
return BaseResponse.<T>builder()
.success(true)
.message(message)
.data(data)
.build();
}

public static BaseResponse<?> of(boolean isSuccess, String message) {
Expand Down
16 changes: 0 additions & 16 deletions smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java

This file was deleted.

26 changes: 4 additions & 22 deletions smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.smeem.api.diary.api;

import com.smeem.api.common.BaseResponse;
import com.smeem.api.common.ErrorResponse;
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 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 Down Expand Up @@ -38,25 +35,10 @@ public interface DiaryApi {
@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(schema = @Schema(implementation = ErrorResponse.class))
),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 토큰",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))
)
@ApiResponse(responseCode = "201", description = "성공"),
@ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청", content = @Content),
@ApiResponse(responseCode = "401", description = "유효하지 않은 토큰", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content)
})
ResponseEntity<BaseResponse<DiaryGetResponse>> getDiaryDetail(@PathVariable long diaryId);

Expand Down

0 comments on commit bc023ad

Please sign in to comment.