Skip to content

Commit

Permalink
Docs: API 문서 수정
Browse files Browse the repository at this point in the history
- 멤버 API docs 문서 수정

Resolves: feat/#58
  • Loading branch information
haeyonghahn committed Mar 10, 2024
1 parent d9f6d53 commit 1eeaad9
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 54 deletions.
17 changes: 14 additions & 3 deletions src/docs/asciidoc/index.adoc
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[]
32 changes: 19 additions & 13 deletions src/docs/asciidoc/member.adoc
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[]
6 changes: 5 additions & 1 deletion src/main/java/com/dnd/gooding/user/query/dto/MemberData.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public class MemberData {
protected MemberData() {}

@Builder
public MemberData(String id, String name) {
public MemberData(String id, String name, List<Email> emails, List<Interest> interests, String oAuthId, String imageUrl) {
this.id = id;
this.name = name;
this.emails = emails;
this.interests = interests;
this.oAuthId = oAuthId;
this.imageUrl = imageUrl;
}

public String getId() {
Expand Down
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)));
}
}
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}}
|===

0 comments on commit 1eeaad9

Please sign in to comment.