Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] 마이페이지 API REST Docs 작성 #107

Merged
merged 6 commits into from
May 24, 2024

Conversation

pdohyung
Copy link
Member

@pdohyung pdohyung commented May 22, 2024

💡 연관된 이슈

close #101

📝 작업 내용

  • 별점 생성, 삭제, 페이지 조회
  • 한줄평 생성, 삭제, 페이지 조회
  • 유저 상세 조회
  • 별점 수정, 단일 조회 API 추가

해당 API 추가하고 REST Docs도 작성했습니다.

💬 리뷰 요구 사항

궁금한 점 있으시면 코멘트 남겨주세요 !

@pdohyung pdohyung added the 📃 Docs 문서 관련 label May 22, 2024
@pdohyung pdohyung self-assigned this May 22, 2024
@pdohyung pdohyung linked an issue May 22, 2024 that may be closed by this pull request
2 tasks
@pdohyung pdohyung requested review from jwooo and AHNYUNKI May 22, 2024 16:36
Copy link
Collaborator

@jwooo jwooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다. 리뷰 확인 부탁 드립니다!

Comment on lines 24 to 97
public class RatingControllerDocsTest extends RestDocsSupport {

private final RatingService ratingService = mock(RatingService.class);

@Override
protected Object initController() {
return new RatingController(ratingService);
}

@DisplayName("별점 생성 API")
@Test
void createRating() throws Exception {
RatingCreateRequest request = RatingCreateRequest.builder()
.bookIsbn("00000001")
.rating("3.5")
.build();

mockMvc.perform(
post("/v1/ratings")
.content(objectMapper.writeValueAsString(request))
.contentType(MediaType.APPLICATION_JSON)
)
.andDo(print())
.andExpect(status().isOk())
.andDo(document("rating/create",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("bookIsbn").type(JsonFieldType.STRING)
.description("책 isbn"),
fieldWithPath("rating").type(JsonFieldType.STRING)
.description("별점")
),
responseFields(
fieldWithPath("code").type(JsonFieldType.NUMBER)
.description("코드"),
fieldWithPath("status").type(JsonFieldType.STRING)
.description("상태"),
fieldWithPath("message").type(JsonFieldType.STRING)
.description("메시지"),
fieldWithPath("data").type(JsonFieldType.NULL)
.description("return data null")
)
));
}

@DisplayName("별점 삭제 API")
@Test
void deleteRating() throws Exception {
mockMvc.perform(
delete("/v1/ratings/{ratingId}", 1)
.contentType(MediaType.APPLICATION_JSON)
)
.andDo(print())
.andExpect(status().isOk())
.andDo(document("rating/delete",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(
parameterWithName("ratingId")
.description("별점 ID")
),
responseFields(
fieldWithPath("code").type(JsonFieldType.NUMBER)
.description("코드"),
fieldWithPath("status").type(JsonFieldType.STRING)
.description("상태"),
fieldWithPath("message").type(JsonFieldType.STRING)
.description("메시지"),
fieldWithPath("data").type(JsonFieldType.NULL)
.description("return data null")
)
));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RatingControllerDocsTest@PatchMapping 테스트가 누락된 거 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 반영했습니다 !

Copy link
Member

@AHNYUNKI AHNYUNKI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!
정우님이 말씀하신 REST Docs 테스트만 수정하시면 될거같습니다!

@pdohyung pdohyung merged commit 154dcad into develop May 24, 2024
1 check passed
@pdohyung pdohyung deleted the docs/101-mypage-api-restdocs branch May 24, 2024 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📃 Docs 문서 관련
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs] 마이페이지 API REST Docs 작성
3 participants