-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
97 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
= Gooding API 문서 | ||
= Gooding API 문서 가이드 | ||
한해용, <yong80211@gmail.com> | ||
v2024.03.11, 2024-03-11 | ||
:doctype: book | ||
:icons: font | ||
:source-highlighter: coderay | ||
:toc: left | ||
:toc-title: 목차 | ||
:toclevels: 3 | ||
:sectlinks: | ||
:sectnums: | ||
|
||
== 개요 | ||
이 API문서는 'Gooding' 프로젝트의 산출물입니다. | ||
이 API 문서는 'Gooding' 프로젝트의 산출물입니다. | ||
|
||
== API | ||
include::member.adoc | ||
//멤버 | ||
include::member.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
== 멤버(Member) | ||
=== 멤버(Member) | ||
멤버를 등록하고 멤버 정보를 처리할 수 있습니다. | ||
|
||
=== 멤버검색 | ||
==== 멤버검색 | ||
멤버정보를 아이디(ID)를 이용해서 검색할 수 있습니다. | ||
|
||
|==== | ||
[discrete] | ||
===== curl request | ||
include::{snippets}/get-v1-get-member/curl-request.adoc[] | ||
|
||
===== Path parameters | ||
====== /member/{id} | ||
|===== | ||
|속성 |설명 | ||
|
||
|`id` |아이디 | ||
|
||
|==== | ||
|===== | ||
|
||
[discrete] | ||
==== 요청 | ||
include::{snippets}/get-v1-get-member/curl-request.adoc[] | ||
include::{snippets}/get-v1-get-member/httpie-request.adoc[] | ||
include::{snippets}/get-v1-get-member/http-request.adoc[] | ||
===== Request parameters | ||
include::{snippets}/get-v1-get-member/request-parameters.adoc[] | ||
|
||
[discrete] | ||
==== 응답 | ||
include::{snippets}/get-v1-get-member/http-response.adoc[] | ||
include::{snippets}/get-v1-get-member/response-fields.adoc[] | ||
===== Response Fields | ||
include::{snippets}/get-v1-get-member/response-fields.adoc[] | ||
|
||
===== HTTP Request | ||
include::{snippets}/get-v1-get-member/http-request.adoc[] | ||
|
||
===== HTTP Response | ||
include::{snippets}/get-v1-get-member/http-response.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
src/test/java/com/dnd/gooding/unit/user/fixture/MemberDataFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
package com.dnd.gooding.unit.user.fixture; | ||
|
||
import com.dnd.gooding.common.model.Email; | ||
import com.dnd.gooding.common.model.Interest; | ||
import com.dnd.gooding.user.query.dto.MemberData; | ||
import java.util.List; | ||
|
||
public class MemberDataFixture { | ||
|
||
public static MemberData getMember() { | ||
return MemberData.builder().id("[email protected]").name("haeyong").build(); | ||
return MemberData.builder() | ||
.id("[email protected]") | ||
.name("haeyong") | ||
.emails(List.of(new Email("[email protected]"))) | ||
.interests(List.of(new Interest("1", "쇼핑"), new Interest("2", "여행"))) | ||
.oAuthId("2942669123") | ||
.imageUrl( | ||
"http://k.kakaocdn.net/dn/bwXMb4/btsffv6Enze/CWxCrOgCvTAUz5FxUjWLUk/img_640x640.jpg") | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,15 @@ | |
|
||
import static com.dnd.gooding.common.constants.Constant.*; | ||
import static com.dnd.gooding.documenation.DocumentUtils.*; | ||
import static javax.management.openmbean.SimpleType.*; | ||
import static org.springframework.restdocs.payload.JsonFieldType.*; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.*; | ||
import static org.springframework.restdocs.request.RequestDocumentation.*; | ||
|
||
import com.dnd.gooding.annotations.RestDocsTest; | ||
import com.dnd.gooding.documenation.MockMvcFactory; | ||
import com.dnd.gooding.unit.user.fixture.MemberDataFixture; | ||
import com.dnd.gooding.user.query.application.MemberQueryService; | ||
import com.dnd.gooding.user.query.dto.MemberData; | ||
import com.dnd.gooding.user.ui.MemberController; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.InjectMocks; | ||
|
@@ -15,50 +20,45 @@ | |
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; | ||
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; | ||
import org.springframework.restdocs.payload.FieldDescriptor; | ||
import org.springframework.restdocs.request.ParameterDescriptor; | ||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers; | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; | ||
|
||
import com.dnd.gooding.annotations.RestDocsTest; | ||
import com.dnd.gooding.documenation.MockMvcFactory; | ||
import com.dnd.gooding.user.query.application.MemberQueryService; | ||
import com.dnd.gooding.user.ui.MemberController; | ||
|
||
@DisplayName("멤버API 문서화") | ||
@RestDocsTest | ||
class MemberControllerDocsTest { | ||
|
||
@Mock | ||
private MemberQueryService memberQueryService; | ||
@InjectMocks | ||
private MemberController memberController; | ||
@Mock private MemberQueryService memberQueryService; | ||
@InjectMocks private MemberController memberController; | ||
|
||
@DisplayName("검색 : 멤버정보 조회") | ||
@Test | ||
void member(RestDocumentationContextProvider contextProvider) throws Exception { | ||
String responseSource = """ | ||
{ | ||
"id":"[email protected]", | ||
"name":"haeyong" | ||
}"""; | ||
@DisplayName("검색 : 멤버정보 조회") | ||
@Test | ||
void member(RestDocumentationContextProvider contextProvider) throws Exception { | ||
MemberData expectMemberData = MemberDataFixture.getMember(); | ||
|
||
// Mockito.when(memberQueryService.getMember(Mockito.any())) | ||
// .thenReturn(Optional.of()); | ||
Mockito.when(memberQueryService.getMember("[email protected]")).thenReturn(expectMemberData); | ||
|
||
// var responseFieldDescriptors = new FieldDescriptor[]{ | ||
// fieldWithPath("code").type(STRING).description("응답코드(정상: 0000)"), | ||
// fieldWithPath("message").type(STRING).description("응답메시지(정상: OK)") | ||
// }; | ||
var responseFieldDescription = | ||
new FieldDescriptor[] { | ||
fieldWithPath("id").type(STRING).description("멤버아이디"), | ||
fieldWithPath("name").type(STRING).description("이름"), | ||
fieldWithPath("emails[].address").type(STRING).description("이메일"), | ||
fieldWithPath("interests[].interestCode").type(STRING).description("관심사코드"), | ||
fieldWithPath("interests[].interestName").type(STRING).description("관심사이름"), | ||
fieldWithPath("oAuthId").type(STRING).description("소셜로그인일련번호"), | ||
fieldWithPath("imageUrl").type(STRING).description("프로필사진"), | ||
}; | ||
|
||
String id = "[email protected]"; | ||
String id = "[email protected]"; | ||
|
||
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, memberController) | ||
.perform(RestDocumentationRequestBuilders.get("/api/v1/member/{id}", id)) | ||
.andDo(MockMvcResultHandlers.print()) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andDo(MockMvcRestDocumentation.document("get-v1-get-member", | ||
getDocumentRequest(), | ||
getDocumentResponse() | ||
)); | ||
} | ||
MockMvcFactory.getRestDocsMockMvc(contextProvider, HOST_LOCAL, memberController) | ||
.perform(RestDocumentationRequestBuilders.get("/api/v1/member/{id}", id)) | ||
.andDo(MockMvcResultHandlers.print()) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andDo( | ||
MockMvcRestDocumentation.document( | ||
"get-v1-get-member", | ||
getDocumentRequest(), | ||
getDocumentResponse(), | ||
responseFields(responseFieldDescription))); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...test/resources/org/springframework/restdocs/templates/asciidoctor/response-fields.snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|=== | ||
|필드|타입|필수값|설명|형식 | ||
|
||
{{#fields}} | ||
|{{path}} | ||
|{{type}} | ||
|{{^optional}}true{{/optional}} | ||
a|{{description}} | ||
a|{{#format}}{{format}}{{/format}}{{^format}}{{/format}} | ||
{{/fields}} | ||
|=== |