Skip to content

Commit

Permalink
Refactor: Swagger와 노션 API 명세서 싱크 동기화
Browse files Browse the repository at this point in the history
Refactor: Swagger와 노션 API 명세서 싱크 동기화
  • Loading branch information
sansan20535 authored Jan 21, 2025
2 parents 70ac65b + 5d1ee4f commit 9b3522f
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public ResponseEntity<BaseResponse<CommentsAndSubCommentsResponse>> getPostComme
return SuccessResponse.success(SuccessMessage.OK, postComments);
}

@GetMapping("/my")
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMyComments(
@GetMapping("/members")
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMemberComments(
@RequestParam(name = "nickname", required = false) final String nickname
) {
return SuccessResponse.success(SuccessMessage.OK, commentService.getMyComments(nickname, PrincipalHandler.getMemberIdFromPrincipal()));
return SuccessResponse.success(SuccessMessage.OK, commentService.getMemberComments(nickname, PrincipalHandler.getMemberIdFromPrincipal()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public ResponseEntity<BaseResponse<Void>> deletePostSubComment(
@Parameter(name = "postId", description = "게시글 아이디", in = ParameterIn.PATH, required = true, schema = @Schema(type = "Long"))
public ResponseEntity<BaseResponse<CommentsAndSubCommentsResponse>> getPostComments(final Long postId);

@Operation(summary = "나의 댓글&대댓글 조회 API", description = "내가 단 댓글과 대댓글을 조회하는 API입니다. ")
@Operation(summary = "사용자 댓글 & 대댓글 조회 API", description = "사용자의 댓글과 대댓글을 조회하는 API입니다. ")
@ApiResponse(
responseCode = "200",
description = "요청에 성공했습니다.")
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMyComments (
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMemberComments(
@RequestParam final String nickname
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public CommentsAndSubCommentsResponse getPostComments(final Long postId, final L
return CommentsAndSubCommentsResponse.of(commentDtos);
}

public MyAllCommentsResponse getMyComments(final String nickname, final Long memberId) {
public MyAllCommentsResponse getMemberComments(final String nickname, final Long memberId) {
final Long selectedMemberId = (nickname != null ) ? findMemberByNickname(nickname): memberId;
final List<Comment> comments = commentRepository.findByMemberIdOrderByCreatedAtAsc(selectedMemberId);
final List<Long> commentIds = comments.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.swagger.v3.oas.annotations.media.Schema;

public record LoginRequest(
@Schema(description = "소셜 플랫폼", example = "KAKAO")
@Schema(description = "소셜 플랫폼", example = "KAKAO or GOOGLE or APPLE")
Platform platform,
@Schema(description = "코드", example = "egagasdgasdgdagdasgasgasdgdasgasdglkj")
String code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public record PetResponse(
String petName,
@Schema(description = "애완동물 성별",example = "12")
int petAge,
@Schema(description = "애완동물 나이", example = "애완동물 성별")
@Schema(description = "애완동물 나이", example = "M or F")
Gender petGender,
@Schema(description = "종 아이디", example = "1")
Long breedId,
Expand All @@ -32,4 +32,4 @@ public record PetResponse(
public static PetResponse of(final Long petId, final String petImage, final String petName,final int petAge, final Gender petGender, final Long breedId, final String breed, final Long animalId, final String animal, final List<PetDiseaseResponse> diseases, final List<PetSymptomResponse> symptoms) {
return new PetResponse(petId, petImage, petName, petAge, petGender, breedId, breed, animalId, animal, diseases, symptoms);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public record PetCreateRequest(
@Schema(description = "반려동물 이름", example = "포리")
String name,

@Schema(description = "성별", example = "F")
@Schema(description = "성별", example = "F or M")
Gender gender,

@Schema(description = "나이", example = "12")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public record PetUpdateRequest(
@Schema(description = "반려동물 이름", example = "포리")
String name,

@Schema(description = "성별", example = "F")
@Schema(description = "성별", example = "F or M")
Gender gender,

@Schema(description = "나이", example = "12")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public ResponseEntity<BaseResponse<PostListResponse>> getPosts(
return SuccessResponse.success(SuccessMessage.OK, postService.getPosts(PrincipalHandler.getMemberIdFromPrincipal(), postListRequest.keyword(),
postListRequest.animalIds(), postListRequest.symptomIds(), postListRequest.diseaseIds(),
postListRequest.sortBy(), postListRequest.cursorId(), postListRequest.categoryId(),
postListRequest.likeCount(), postListRequest.createAt()));
postListRequest.likeCount(), postListRequest.createdAt()));
}

@GetMapping("/my")
@GetMapping("/members")
public ResponseEntity<BaseResponse<MemberPostsResponse>> getMemberPosts(
@RequestParam(name = "nickname", required = false) final String nickname
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cocos.cocos.api.post.controller;

import com.cocos.cocos.api.post.dto.request.PostListRequest;
import com.cocos.cocos.api.post.dto.request.PostRequest;
import com.cocos.cocos.api.post.dto.response.*;
import com.cocos.cocos.common.response.BaseResponse;
Expand All @@ -10,6 +11,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;

@Tag(name = "Post Controller", description = "게시글 관련 API")
public interface PostControllerSwagger {
Expand Down Expand Up @@ -52,4 +54,13 @@ public interface PostControllerSwagger {
description = "사용자 게시글 조회 성공")
@Parameter(name = "nickname", description = "모모", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "String"))
public ResponseEntity<BaseResponse<MemberPostsResponse>> getMemberPosts(final String nickname);


@Operation(summary = "게시글 리스트 조회 API", description = "사용자 게시글을 조회하는 API입니다.")
@ApiResponse(
responseCode = "200",
description = "게시글 리스트 조회 성공")
public ResponseEntity<BaseResponse<PostListResponse>> getPosts(
@RequestBody final PostListRequest postListRequest
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public record PostListRequest(
@Schema(description = "마지막 게시글 좋아요 수 아이디", example = "1 or null")
Long likeCount,
@Schema(description = "마지막 게시글 생성일", example = "YYYY-MM-DD~ or null")
LocalDateTime createAt
LocalDateTime createdAt
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.List;

public record SearchResponse(
@Schema(description = "검색 내역", example = "1")
@Schema(description = "검색 내역")
List<KeywordResponse> keywords
) {
public static SearchResponse of(final List<KeywordResponse> keywords) {
Expand Down

0 comments on commit 9b3522f

Please sign in to comment.