From 0f3e75eb31747bdd2381a397ffbdc2fa7c548107 Mon Sep 17 00:00:00 2001 From: juno-junho Date: Sun, 19 May 2024 19:04:01 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20api=20docs=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EB=B0=8F=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/exception-api.adoc | 26 ++++++++- src/docs/asciidoc/index.adoc | 2 + src/docs/asciidoc/profanity-api.adoc | 58 +++++++++++++++++++ .../controller/ProfanityControllerTest.java | 17 +----- 4 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 src/docs/asciidoc/profanity-api.adoc diff --git a/src/docs/asciidoc/exception-api.adoc b/src/docs/asciidoc/exception-api.adoc index 13b49cd8..d6720ee8 100644 --- a/src/docs/asciidoc/exception-api.adoc +++ b/src/docs/asciidoc/exception-api.adoc @@ -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 파일 생성에 실패했습니다 + -|==== diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 5eba2bb7..1078929f 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -28,5 +28,7 @@ include::board-api.adoc[] include::notification-api.adoc[] +include::profanity-api.adoc[] + include::exception-api.adoc[] diff --git a/src/docs/asciidoc/profanity-api.adoc b/src/docs/asciidoc/profanity-api.adoc new file mode 100644 index 00000000..5385a8d0 --- /dev/null +++ b/src/docs/asciidoc/profanity-api.adoc @@ -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: diff --git a/src/test/java/com/spaceclub/global/annotation/profanity/controller/ProfanityControllerTest.java b/src/test/java/com/spaceclub/global/annotation/profanity/controller/ProfanityControllerTest.java index f812a381..4b46ad02 100644 --- a/src/test/java/com/spaceclub/global/annotation/profanity/controller/ProfanityControllerTest.java +++ b/src/test/java/com/spaceclub/global/annotation/profanity/controller/ProfanityControllerTest.java @@ -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; @@ -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( @@ -104,9 +100,6 @@ class ProfanityControllerTest { preprocessResponse(prettyPrint()), requestParts( partWithName("file").description("금칙어 목록 파일") - ), - requestHeaders( - headerWithName(AUTHORIZATION).description("액세스 토큰") ) ) ); @@ -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") ) ) ); @@ -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())) @@ -156,9 +148,6 @@ class ProfanityControllerTest { preprocessResponse(prettyPrint()), requestFields( fieldWithPath("word").description("금칙어") - ), - requestHeaders( - headerWithName(AUTHORIZATION).description("액세스 토큰") ) ) ); @@ -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())) @@ -186,9 +174,6 @@ class ProfanityControllerTest { preprocessResponse(prettyPrint()), requestFields( fieldWithPath("word").description("금칙어") - ), - requestHeaders( - headerWithName(AUTHORIZATION).description("액세스 토큰") ) ) );