Skip to content

Commit

Permalink
feat: api docs 생성 및 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
juno-junho committed May 19, 2024
1 parent 8747397 commit 0f3e75e
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 17 deletions.
26 changes: 25 additions & 1 deletion src/docs/asciidoc/exception-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,33 @@
|`+KAKAO_UNLINK_FAIL+`
|카카오 계정 연결 해제에 실패했습니다




|====

=== 금칙어

|====
|코드 |코드 설명

|`+FAIL_BAD_WORD_SETUP+`
|비속어 목록 Trie 생성 실패

|`+BAD_WORD_DETECTED+`
|비속어가 발견 되었습니다

|`+INVALID_EXTENSION+`
|md,txt 파일만 업로드 가능합니다

|`+FAILED_TO_SAVE+`
|금칙어 저장에 실패했습니다

|`+BAD_WORD_ALREADY_EXISTS+`
|이미 존재하는 금칙어 입니다

|`+FAILED_TO_CREATE_CSV+`
|csv 파일 생성에 실패했습니다



|====
2 changes: 2 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ include::board-api.adoc[]

include::notification-api.adoc[]

include::profanity-api.adoc[]

include::exception-api.adoc[]

58 changes: 58 additions & 0 deletions src/docs/asciidoc/profanity-api.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
:sectnums:
== 금칙어 관리

=== 금칙어를 파일로 등록
:sectnums!:

==== Request
include::{snippets}/profanity/upload-banword-file/http-request.adoc[]

===== Request Part
include::{snippets}/profanity/upload-banword-file/request-parts.adoc[]

==== Response
include::{snippets}/profanity/upload-banword-file/http-response.adoc[]

:sectnums:

=== 금칙어 정보 csv 파일로 저장
:sectnums!:

==== Request
include::{snippets}/profanity/download-csv-file/http-request.adoc[]

==== Response
include::{snippets}/profanity/download-csv-file/http-response.adoc[]

===== Response Body
include::{snippets}/profanity/download-csv-file/response-fields.adoc[]

:sectnums:

=== 금칙어 정보 단일 추가
:sectnums!:

==== Request
include::{snippets}/profanity/add-single-banword/http-request.adoc[]

===== Request Body
include::{snippets}/profanity/add-single-banword/request-fields.adoc[]

==== Response
include::{snippets}/profanity/add-single-banword/http-response.adoc[]

:sectnums:

=== 금칙어 정보 단일 삭제
:sectnums!:

==== Request
include::{snippets}/profanity/delete-banword/http-request.adoc[]

===== Request Body
include::{snippets}/profanity/delete-banword/request-fields.adoc[]

==== Response
include::{snippets}/profanity/delete-banword/http-response.adoc[]

:sectnums:
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doNothing;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
Expand Down Expand Up @@ -95,7 +92,6 @@ class ProfanityControllerTest {
.file(file)
.characterEncoding(UTF_8)
.contentType(MULTIPART_FORM_DATA)
.header(AUTHORIZATION, "access token")
.with(csrf()))
.andExpect(status().isCreated())
.andDo(
Expand All @@ -104,9 +100,6 @@ class ProfanityControllerTest {
preprocessResponse(prettyPrint()),
requestParts(
partWithName("file").description("금칙어 목록 파일")
),
requestHeaders(
headerWithName(AUTHORIZATION).description("액세스 토큰")
)
)
);
Expand All @@ -127,7 +120,7 @@ class ProfanityControllerTest {
.andDo(
document("profanity/download-csv-file",
responseFields(
fieldWithPath("url").description("The full path to the created CSV file.")
fieldWithPath("url").description("csv 파일 다운로드 s3 url")
)
)
);
Expand All @@ -145,7 +138,6 @@ class ProfanityControllerTest {

// when, then
mockMvc.perform(post("/api/v1/profanities")
.header(AUTHORIZATION, "access token")
.contentType(APPLICATION_JSON)
.content(mapper.writeValueAsString(request))
.with(csrf()))
Expand All @@ -156,9 +148,6 @@ class ProfanityControllerTest {
preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("word").description("금칙어")
),
requestHeaders(
headerWithName(AUTHORIZATION).description("액세스 토큰")
)
)
);
Expand All @@ -175,7 +164,6 @@ class ProfanityControllerTest {

// when, then
mockMvc.perform(delete("/api/v1/profanities")
.header(AUTHORIZATION, "access token")
.contentType(APPLICATION_JSON)
.content(mapper.writeValueAsString(request))
.with(csrf()))
Expand All @@ -186,9 +174,6 @@ class ProfanityControllerTest {
preprocessResponse(prettyPrint()),
requestFields(
fieldWithPath("word").description("금칙어")
),
requestHeaders(
headerWithName(AUTHORIZATION).description("액세스 토큰")
)
)
);
Expand Down

0 comments on commit 0f3e75e

Please sign in to comment.