Skip to content

Commit

Permalink
doc : Tag Entity API 명세서 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
chrkb1569 committed Oct 19, 2023
1 parent 4507a8d commit a2c1212
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 12 deletions.
86 changes: 86 additions & 0 deletions src/docs/asciidoc/tag.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
= TAG 차량 특징 카드 API
:doctype: book
:icons: font
:source-highlighter: highlightjs
:toc: left
:toclevels: 3

== 차량 특징 카드 조회
=== 1. 차량에 등록된 차량 특징 카드가 존재하지 않을 경우, 오류를 반환한다
==== HTTP Request
include::{snippets}/Tag/List/Failure/Case1/http-request.adoc[]

Path Variable
include::{snippets}/Tag/List/Failure/Case1/path-parameters.adoc[]

==== HTTP Response
include::{snippets}/Tag/List/Failure/Case1/http-response.adoc[]
include::{snippets}/Tag/List/Failure/Case1/response-fields.adoc[]

=== 2. 차량에 등록된 차량 특징 카드 조회에 성공한다
==== HTTP Request
include::{snippets}/Tag/List/Success/http-request.adoc[]

Path Variable
include::{snippets}/Tag/List/Success/path-parameters.adoc[]

==== HTTP Response
include::{snippets}/Tag/List/Success/http-response.adoc[]
include::{snippets}/Tag/List/Success/response-fields.adoc[]

== 차량 특징 카드 삭제
=== 1. 유효하지 않은 tagId를 입력 받은 경우, 오류를 반환한다
==== HTTP Request
include::{snippets}/Tag/Delete/Failure/Case1/http-request.adoc[]

Query String
include::{snippets}/Tag/Delete/Failure/Case1/query-parameters.adoc[]

Path Variable
include::{snippets}/Tag/Delete/Failure/Case1/path-parameters.adoc[]

==== HTTP Response
include::{snippets}/Tag/Delete/Failure/Case1/http-response.adoc[]
include::{snippets}/Tag/Delete/Failure/Case1/response-fields.adoc[]

=== 2. 유효하지 않은 carId를 입력 받은 경우, 오류를 반환한다
==== HTTP Request
include::{snippets}/Tag/Delete/Failure/Case2/http-request.adoc[]

Query String
include::{snippets}/Tag/Delete/Failure/Case2/query-parameters.adoc[]

Path Variable
include::{snippets}/Tag/Delete/Failure/Case2/path-parameters.adoc[]

==== HTTP Response
include::{snippets}/Tag/Delete/Failure/Case2/http-response.adoc[]
include::{snippets}/Tag/Delete/Failure/Case2/response-fields.adoc[]

=== 3. Tag와 Car Entity가 서로 연관된 관계가 아닐 경우, 오류를 반환한다
==== HTTP Request
include::{snippets}/Tag/Delete/Failure/Case3/http-request.adoc[]

Query String
include::{snippets}/Tag/Delete/Failure/Case3/query-parameters.adoc[]

Path Variable
include::{snippets}/Tag/Delete/Failure/Case3/path-parameters.adoc[]

==== HTTP Response
include::{snippets}/Tag/Delete/Failure/Case3/http-response.adoc[]
include::{snippets}/Tag/Delete/Failure/Case3/response-fields.adoc[]

=== 4. 차량 특징 카드 삭제에 성공한다
==== HTTP Request
include::{snippets}/Tag/Delete/Success/http-request.adoc[]

Query String
include::{snippets}/Tag/Delete/Success/query-parameters.adoc[]

Path Variable
include::{snippets}/Tag/Delete/Success/path-parameters.adoc[]

==== HTTP Response
include::{snippets}/Tag/Delete/Success/http-response.adoc[]
include::{snippets}/Tag/Delete/Success/response-fields.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public void throwExceptionByEmptyList() throws Exception {
responseFields(
fieldWithPath("status").type(JsonFieldType.NUMBER).description("HTTP 상태 코드"),
fieldWithPath("code").type(JsonFieldType.STRING).description("커스텀 상태 코드"),
fieldWithPath("message").type(JsonFieldType.STRING).description("상태 메시지"))
fieldWithPath("message").type(JsonFieldType.STRING).description("상태 메시지")
)
)
);

Expand All @@ -73,7 +74,8 @@ public void throwExceptionByEmptyList() throws Exception {
@DisplayName("차량에 등록된 차량 특징 카드 조회에 성공한다")
public void successToGetList() throws Exception {
// given
List<TagResponse> response = new ArrayList<>();
List<TagResponse> response = getResponseList();

doReturn(response)
.when(tagService)
.getTagList(anyLong());
Expand All @@ -91,7 +93,14 @@ public void successToGetList() throws Exception {
"Tag/List/Success",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(parameterWithName("carId").description("차량 ID"))
pathParameters(parameterWithName("carId").description("차량 ID")),
responseFields(
fieldWithPath("status").type(JsonFieldType.NUMBER).description("HTTP 상태 코드"),
fieldWithPath("code").type(JsonFieldType.STRING).description("커스텀 상태 코드"),
fieldWithPath("message").type(JsonFieldType.STRING).description("상태 메시지"),
fieldWithPath("result[0].id").type(JsonFieldType.NUMBER).description("차량 특징 카드 Id"),
fieldWithPath("result[0].name").type(JsonFieldType.STRING).description("차량 특징")
)
)
);
}
Expand All @@ -117,7 +126,7 @@ public void throwExceptionByInvalidTagId() throws Exception {
// when
MockHttpServletRequestBuilder request = RestDocumentationRequestBuilders
.delete(BASE_URL, errorTagId)
.param("carId", String.valueOf(carId));
.queryParam("carId", String.valueOf(carId));

// then
final BaseResponseStatus expectException = BaseResponseStatus.TAG_NOT_FOUND_ERROR;
Expand All @@ -136,7 +145,12 @@ public void throwExceptionByInvalidTagId() throws Exception {
"Tag/Delete/Failure/Case1",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(parameterWithName("tagId").description("차량 특징 카드 ID")),
pathParameters(
parameterWithName("tagId").description("차량 특징 카드 ID")
),
queryParameters(
parameterWithName("carId").description("차량 Id")
),
responseFields(
fieldWithPath("status").type(JsonFieldType.NUMBER).description("HTTP 상태 코드"),
fieldWithPath("code").type(JsonFieldType.STRING).description("커스텀 상태 코드"),
Expand All @@ -156,7 +170,7 @@ public void throwExceptionByInvalidCarId() throws Exception {
// when
MockHttpServletRequestBuilder request = RestDocumentationRequestBuilders
.delete(BASE_URL, tagId)
.param("carId", String.valueOf(errorCarId));
.queryParam("carId", String.valueOf(errorCarId));

// then
final BaseResponseStatus expectException = BaseResponseStatus.CAR_NOT_FOUND_ERROR;
Expand All @@ -175,7 +189,12 @@ public void throwExceptionByInvalidCarId() throws Exception {
"Tag/Delete/Failure/Case2",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(parameterWithName("tagId").description("차량 특징 카드 ID")),
pathParameters(
parameterWithName("tagId").description("차량 특징 카드 ID")
),
queryParameters(
parameterWithName("carId").description("차량 Id")
),
responseFields(
fieldWithPath("status").type(JsonFieldType.NUMBER).description("HTTP 상태 코드"),
fieldWithPath("code").type(JsonFieldType.STRING).description("커스텀 상태 코드"),
Expand All @@ -195,7 +214,7 @@ public void throwExceptionByInvalidMember() throws Exception {
// when
MockHttpServletRequestBuilder request = RestDocumentationRequestBuilders
.delete(BASE_URL, tagId)
.param("carId", String.valueOf(carId));
.queryParam("carId", String.valueOf(carId));

// then
final BaseResponseStatus expectException = BaseResponseStatus.CAR_NOT_MATCH_ERROR;
Expand All @@ -214,7 +233,12 @@ public void throwExceptionByInvalidMember() throws Exception {
"Tag/Delete/Failure/Case3",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(parameterWithName("tagId").description("차량 특징 카드 ID")),
pathParameters(
parameterWithName("tagId").description("차량 특징 카드 ID")
),
queryParameters(
parameterWithName("carId").description("차량 Id")
),
responseFields(
fieldWithPath("status").type(JsonFieldType.NUMBER).description("HTTP 상태 코드"),
fieldWithPath("code").type(JsonFieldType.STRING).description("커스텀 상태 코드"),
Expand All @@ -234,7 +258,7 @@ public void successToDelete() throws Exception {
// when
MockHttpServletRequestBuilder request = RestDocumentationRequestBuilders
.delete(BASE_URL, tagId)
.param("carId", String.valueOf(carId));
.queryParam("carId", String.valueOf(carId));

// then
mockMvc.perform(request)
Expand All @@ -245,9 +269,27 @@ public void successToDelete() throws Exception {
"Tag/Delete/Success",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
pathParameters(parameterWithName("tagId").description("차량 특징 카드 ID"))
pathParameters(
parameterWithName("tagId").description("차량 특징 카드 ID")
),
queryParameters(
parameterWithName("carId").description("차량 Id")
),
responseFields(
fieldWithPath("status").type(JsonFieldType.NUMBER).description("HTTP 상태 코드"),
fieldWithPath("code").type(JsonFieldType.STRING).description("커스텀 상태 코드"),
fieldWithPath("message").type(JsonFieldType.STRING).description("상태 메시지")
)
)
);
}
}
private List<TagResponse> getResponseList() {
List<TagResponse> responseList = new ArrayList<>();

responseList.add(new TagResponse(1L, "Tag"));

return responseList;
}
}

}

0 comments on commit a2c1212

Please sign in to comment.