[ restDocs ]
mockMvc.perform(
RestDocumentationRequestBuilders.get("/jmt/member")
.param("page", "1")
.param("size", "1")
.param("sort", "memberId,desc")
).andExpect(status().isOk())
.andExpect(jsonPath("$.data[0].memberId").value(1))
.andExpect(jsonPath("$.data[0].name").value("영롱"))
.andExpect(jsonPath("$.data[0].email").value("aaa@naver.com"))
.andExpect(jsonPath("$.data[0].phone").value("010-1111-2222"))
.andExpect(jsonPath("$.data[0].stampCount").value(6))
.andExpect(jsonPath("$.data[0].status").value("활동 회원"))
.andExpect(jsonPath("$.data[0].createdAt").value("2023-04-03T03:03:00"))
.andExpect(jsonPath("$.data[0].modifiedAt").value("2023-04-03T03:03:00"))
.andExpect(jsonPath("$.pageInfo.pageNumber").value(pageRequest.getPageNumber()))
.andExpect(jsonPath("$.pageInfo.size").value(pageRequest.getPageSize()))
.andExpect(jsonPath("$.pageInfo.totalPages").value(1))
.andExpect(jsonPath("$.pageInfo.totalElements").value(1))
.andDo(document("get-members",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
requestParameters(
parameterWithName("page").description("조회 페이지 번호"),
parameterWithName("size").description("페이지 내 요소 갯수"),
parameterWithName("sort").description("정렬 기준 및 방식. ex) memberId,desc")
),
responseFields(
fieldWithPath("data[0].memberId").description("회원 번호"),
fieldWithPath("data[0].name").description("회원 이름"),
fieldWithPath("data[0].email").description("이메일"),
fieldWithPath("data[0].phone").description("휴대폰 번호"),
fieldWithPath("data[0].stampCount").description("스탬프 갯수"),
fieldWithPath("data[0].status").description("회원 상태"),
fieldWithPath("data[0].createdAt").description("회원 가입 날짜"),
fieldWithPath("data[0].modifiedAt").description("회원 정보 업데이트 날짜"),
fieldWithPath("pageInfo.pageNumber").description("페이지 번호"),
fieldWithPath("pageInfo.size").description("페이지 내 요소 갯수"),
fieldWithPath("pageInfo.totalPages").description("전체 페이지 수"),
fieldWithPath("pageInfo.totalElements").description("전체 요소 갯수")
)
));
void patchMember() throws Exception {
ConstraintDescriptions requestConstraints = new ConstraintDescriptions(MemberDto.patchDto.class);
List<String> nameAttribute = requestConstraints.descriptionsForProperty("name");
List<String> phoneAttribute = requestConstraints.descriptionsForProperty("phone");
... 이렇게 변경} ```
:sectnums:
:toc: left
:toclevels: 4
:toc-title: JMT
:source-highlighter: prettify
<느낀 점>
restDocs로 API 문서 만드는 거 생각보다 까다로웠다. 어제 밤부터 오늘까지 했음★
진짜 온갖 사이트 들어가서 다 찾아본 듯.
늘 그렇듯이 거의 다 온 것 같은데 마지막에 커스텀 스니핏 작성에서 막혔는데, 갓갓갓 동기님께서 도와주심 ㅠㅠ
내일은 다음 단계로 넘어간다!
만들고 있는 시스템을 확장 & 재구성 & 리팩토링 할 예정.
시큐리티도 적용해보려고 한다.
발등에 불,, 불,, 불,,
프로젝트 진짜 코앞인 거 실화냐🥲
화이팅이다.