From 0c518f8b3dd9f1d4bf2d8369608e8acedb87f456 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 01:03:03 +0900 Subject: [PATCH 01/32] =?UTF-8?q?test:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ootw/user/controller/UserControllerTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/test/java/com/backendoori/ootw/user/controller/UserControllerTest.java b/src/test/java/com/backendoori/ootw/user/controller/UserControllerTest.java index bc8b9363..62f9ee58 100644 --- a/src/test/java/com/backendoori/ootw/user/controller/UserControllerTest.java +++ b/src/test/java/com/backendoori/ootw/user/controller/UserControllerTest.java @@ -8,8 +8,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; import java.util.stream.Stream; import com.backendoori.ootw.exception.UserNotFoundException; import com.backendoori.ootw.security.jwt.TokenProvider; @@ -300,10 +298,6 @@ private LoginDto generateLoginDto() { return new LoginDto(email, password); } - private String removeMills(LocalDateTime localDateTime) { - return localDateTime.truncatedTo(ChronoUnit.SECONDS).toString(); - } - static class InvalidEmailProvider implements ArgumentsProvider { @Override From 3d5b136a9cd15d7e94dcbd611611cac813465820 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 01:27:35 +0900 Subject: [PATCH 02/32] =?UTF-8?q?chore:=20restdocs=20gradle=20task=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/build.gradle b/build.gradle index 3227ecfb..5b413dc0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'org.springframework.boot' version '3.2.0' id 'io.spring.dependency-management' version '1.1.4' + id 'org.asciidoctor.jvm.convert' version '4.0.1' id 'java' id 'jacoco' id 'checkstyle' @@ -48,15 +49,23 @@ dependencies { testImplementation 'com.icegreen:greenmail-junit5:2.0.1' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' + testImplementation 'org.springframework.restdocs:spring-restdocs-asciidoctor' } jacoco { toolVersion = "0.8.11" } +ext { + snippetsDir = file('build/generated-snippets') +} + test { useJUnitPlatform() + outputs.dir snippetsDir + finalizedBy asciidoctor finalizedBy jacocoTestReport } @@ -103,6 +112,7 @@ jacocoTestCoverageVerification { } } } + dependsOn jacocoTestReport } @@ -114,3 +124,22 @@ checkstyle { "org.checkstyle.google.suppressionxpathfilter.config": "suppressions.xml" ] } + +asciidoctor { + inputs.dir snippetsDir + outputDir 'src/docs/asciidoc' + sources { + include 'index.adoc' + } + + dependsOn test +} + +bootJar { + copy { + from "${asciidoctor.outputDir}" + into 'build/static/docs' + } + + dependsOn asciidoctor +} From 11135393d832cdf7c56037c14c08a9d06cc4c539 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 01:28:34 +0900 Subject: [PATCH 03/32] =?UTF-8?q?test:=20user=20document=20test=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ootw/document/common/ApiDocumentUtil.java | 45 +++++++ .../document/user/UserDocumentationTest.java | 127 ++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 src/test/java/com/backendoori/ootw/document/common/ApiDocumentUtil.java create mode 100644 src/test/java/com/backendoori/ootw/document/user/UserDocumentationTest.java diff --git a/src/test/java/com/backendoori/ootw/document/common/ApiDocumentUtil.java b/src/test/java/com/backendoori/ootw/document/common/ApiDocumentUtil.java new file mode 100644 index 00000000..8a2d37db --- /dev/null +++ b/src/test/java/com/backendoori/ootw/document/common/ApiDocumentUtil.java @@ -0,0 +1,45 @@ +package com.backendoori.ootw.document.common; + +import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; + +import org.springframework.restdocs.operation.preprocess.OperationRequestPreprocessor; +import org.springframework.restdocs.operation.preprocess.OperationResponsePreprocessor; +import org.springframework.restdocs.payload.FieldDescriptor; + +public interface ApiDocumentUtil { + + static OperationRequestPreprocessor getDocumentRequest() { + return preprocessRequest( + modifyUris() + .scheme("https") + .host("docs.api.com") + .removePort(), + prettyPrint()); + } + + static OperationResponsePreprocessor getDocumentResponse() { + return preprocessResponse(prettyPrint()); + } + + static FieldDescriptor field(String name, Object type, String description) { + return fieldWithPath(name) + .type(type) + .description(description); + } + + static FieldDescriptor field(String name, Object type, String description, boolean required) { + if (required) { + return field(name, type, description); + } + + return fieldWithPath(name) + .type(type) + .description(description) + .optional(); + } + +} diff --git a/src/test/java/com/backendoori/ootw/document/user/UserDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/user/UserDocumentationTest.java new file mode 100644 index 00000000..1df294fc --- /dev/null +++ b/src/test/java/com/backendoori/ootw/document/user/UserDocumentationTest.java @@ -0,0 +1,127 @@ +package com.backendoori.ootw.document.user; + +import static com.backendoori.ootw.document.common.ApiDocumentUtil.field; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentRequest; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentResponse; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.backendoori.ootw.user.dto.LoginDto; +import com.backendoori.ootw.user.dto.SignupDto; +import com.backendoori.ootw.user.dto.TokenDto; +import com.backendoori.ootw.user.service.UserService; +import com.fasterxml.jackson.databind.ObjectMapper; +import net.datafaker.Faker; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; + +@WithMockUser +@SpringBootTest +@AutoConfigureMockMvc +@AutoConfigureRestDocs +public class UserDocumentationTest { + + static final String API_PREFIX = "/api/v1/auth"; + static final Faker FAKER = new Faker(); + + @Autowired + MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + + @MockBean + UserService userService; + + @DisplayName("[POST] signup 201 Created") + @Test + void testSignupCreated() throws Exception { + // given + SignupDto signupDto = generateSignupDto(); + + willDoNothing().given(userService) + .signup(signupDto); + + // when + ResultActions actions = mockMvc.perform( + post(API_PREFIX + "/signup") + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(signupDto))); + + // then + actions.andExpect(status().isCreated()) + .andDo( + document("user-signup", + getDocumentRequest(), + getDocumentResponse(), + requestFields( + field("email", JsonFieldType.STRING, "Email 주소"), + field("password", JsonFieldType.STRING, "비밀번호"), + field("nickname", JsonFieldType.STRING, "별명") + ) + ) + ); + } + + @DisplayName("[POST] login 201 Created") + @Test + void testLoginCreated() throws Exception { + // given + LoginDto loginDto = generateLoginDto(); + TokenDto tokenDto = new TokenDto(FAKER.hashing().sha512()); + + given(userService.login(loginDto)).willReturn(tokenDto); + + // when + ResultActions actions = mockMvc.perform( + post(API_PREFIX + "/login") + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(loginDto))); + + // then + actions.andExpect(status().isCreated()) + .andDo( + document("user-login", + getDocumentRequest(), + getDocumentResponse(), + requestFields( + field("email", JsonFieldType.STRING, "Email 주소"), + field("password", JsonFieldType.STRING, "비밀번호") + ), + responseFields( + field("token", JsonFieldType.STRING, "JWT 토큰") + ) + ) + ); + } + + private SignupDto generateSignupDto() { + String email = FAKER.internet().emailAddress(); + String password = FAKER.internet().password(8, 30, true, true, true); + String nickname = FAKER.internet().username(); + + return new SignupDto(email, password, nickname); + } + + private LoginDto generateLoginDto() { + String email = FAKER.internet().emailAddress(); + String password = FAKER.internet().password(8, 30, true, true, true); + + return new LoginDto(email, password); + } + +} From f2e093dadd45901266459a6b76480629964368a7 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 01:29:06 +0900 Subject: [PATCH 04/32] =?UTF-8?q?docs:=20restdocs=20index=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=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/index.adoc | 59 +++ src/docs/asciidoc/index.html | 708 +++++++++++++++++++++++++++++++++++ 2 files changed, 767 insertions(+) create mode 100644 src/docs/asciidoc/index.adoc create mode 100644 src/docs/asciidoc/index.html diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc new file mode 100644 index 00000000..fd7b020d --- /dev/null +++ b/src/docs/asciidoc/index.adoc @@ -0,0 +1,59 @@ +ifndef::snippets[] +:snippets: build/generated-snippets +endif::[] + += #OOTW API Documentation +Doc Writers - 김현우 +:doctype: book +:icons: font +:source-highlighter: highlightjs +:toc: left +:toclevels: 2 +:sectlinks: + += User API + +''' +== 회원가입 + +NOTE: 사용자 회원가입 + +=== Request + +include::{snippets}/user-signup/request-body.adoc[] +include::{snippets}/user-signup/request-fields.adoc[] + +==== Request example + +include::{snippets}/user-signup/http-request.adoc[] + +=== Response + +include::{snippets}/user-signup/response-body.adoc[] + +==== Response example + +include::{snippets}/user-signup/http-response.adoc[] + +== 로그인 + +NOTE: 사용자 로그인 + +=== Request + +include::{snippets}/user-login/request-body.adoc[] +include::{snippets}/user-login/request-fields.adoc[] + +==== Request example + +include::{snippets}/user-login/http-request.adoc[] + +=== Response + +include::{snippets}/user-login/response-body.adoc[] +include::{snippets}/user-login/response-fields.adoc[] + +==== Response example + +include::{snippets}/user-login/http-response.adoc[] + diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html new file mode 100644 index 00000000..cc2b7d8f --- /dev/null +++ b/src/docs/asciidoc/index.html @@ -0,0 +1,708 @@ + + + + + + + + +#OOTW API Documentation + + + + + + + +
+

User API

+
+
+
+
+
+
+

회원가입

+
+
+ + + + + +
+ + +사용자 회원가입 +
+
+
+

Request

+
+
+
{
+  "email" : "rich.bailey@hotmail.com",
+  "password" : "xhxC%&6n6&U75X&b!3#00c612d",
+  "nickname" : "vernice.hauck"
+}
+
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

email

String

Email 주소

password

String

비밀번호

nickname

String

별명

+
+

Request example

+
+
+
POST /api/v1/auth/signup HTTP/1.1
+Content-Type: application/json;charset=UTF-8
+Content-Length: 118
+Host: docs.api.com
+
+{
+  "email" : "rich.bailey@hotmail.com",
+  "password" : "xhxC%&6n6&U75X&b!3#00c612d",
+  "nickname" : "vernice.hauck"
+}
+
+
+
+
+
+

Response

+
+
+
+
+
+
+

Response example

+
+
+
HTTP/1.1 201 Created
+Vary: Origin
+Vary: Access-Control-Request-Method
+Vary: Access-Control-Request-Headers
+
+
+
+
+
+
+
+

로그인

+
+
+ + + + + +
+ + +사용자 로그인 +
+
+
+

Request

+
+
+
{
+  "email" : "esteban.lebsack@hotmail.com",
+  "password" : "w9Y$&udGt!*Qk!T1L*7G^H^"
+}
+
+
+ +++++ + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

email

String

Email 주소

password

String

비밀번호

+
+

Request example

+
+
+
POST /api/v1/auth/login HTTP/1.1
+Content-Type: application/json;charset=UTF-8
+Content-Length: 87
+Host: docs.api.com
+
+{
+  "email" : "esteban.lebsack@hotmail.com",
+  "password" : "w9Y$&udGt!*Qk!T1L*7G^H^"
+}
+
+
+
+
+
+

Response

+
+
+
{
+  "token" : "625f2b57df80357c94b85153ec3cfe788542296a567156caf8d2305b572c56b998028223e12f377867edfa564ae674cae2004b3d25a5e5f92c58d3822ae58782"
+}
+
+
+ +++++ + + + + + + + + + + + + + + +
PathTypeDescription

token

String

JWT 토큰

+
+

Response example

+
+
+
HTTP/1.1 201 Created
+Vary: Origin
+Vary: Access-Control-Request-Method
+Vary: Access-Control-Request-Headers
+Authorization: Bearer 625f2b57df80357c94b85153ec3cfe788542296a567156caf8d2305b572c56b998028223e12f377867edfa564ae674cae2004b3d25a5e5f92c58d3822ae58782
+Content-Type: application/json
+Content-Length: 146
+
+{
+  "token" : "625f2b57df80357c94b85153ec3cfe788542296a567156caf8d2305b572c56b998028223e12f377867edfa564ae674cae2004b3d25a5e5f92c58d3822ae58782"
+}
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file From 9d83e224fb8c17e761e36bd6916a6d08c0c995f6 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 02:19:27 +0900 Subject: [PATCH 05/32] =?UTF-8?q?test:=20certificate=20document=20test=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/CertificateDocumentationTest.java | 102 ++++++++++++++++++ .../controller/CertificateControllerTest.java | 22 ++-- 2 files changed, 113 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/backendoori/ootw/document/user/CertificateDocumentationTest.java diff --git a/src/test/java/com/backendoori/ootw/document/user/CertificateDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/user/CertificateDocumentationTest.java new file mode 100644 index 00000000..ee965e3e --- /dev/null +++ b/src/test/java/com/backendoori/ootw/document/user/CertificateDocumentationTest.java @@ -0,0 +1,102 @@ +package com.backendoori.ootw.document.user; + +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentRequest; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentResponse; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.request.RequestDocumentation.queryParameters; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.backendoori.ootw.user.domain.Certificate; +import com.backendoori.ootw.user.dto.CertifyDto; +import com.backendoori.ootw.user.dto.SendCodeDto; +import com.backendoori.ootw.user.service.CertificateService; +import com.fasterxml.jackson.databind.ObjectMapper; +import net.datafaker.Faker; +import org.apache.commons.lang3.RandomStringUtils; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; + +@WithMockUser +@SpringBootTest +@AutoConfigureMockMvc +@AutoConfigureRestDocs +public class CertificateDocumentationTest { + + static final String API_PREFIX = "/api/v1/auth"; + static final Faker FAKER = new Faker(); + + @Autowired + MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + + @MockBean + CertificateService certificateService; + + @DisplayName("[PATCH] certificate 200 Ok") + @Test + void testCertificateOk() throws Exception { + // given + SendCodeDto sendCodeDto = new SendCodeDto(FAKER.internet().emailAddress()); + MockHttpServletRequestBuilder requestBuilder = patch(API_PREFIX + "/certificate") + .queryParam("email", sendCodeDto.email()) + .contentType(MediaType.APPLICATION_JSON); + + // when + ResultActions actions = mockMvc.perform(requestBuilder); + + // then + actions.andExpect((status().isOk())) + .andDo( + document("certificate", + getDocumentRequest(), + getDocumentResponse(), + queryParameters( + parameterWithName("email").description("Email 주소") + ) + ) + ); + } + + @DisplayName("[PATCH] certify 200 Ok") + @Test + void testCertifyOk() throws Exception { + // given + String email = FAKER.internet().safeEmailAddress(); + String code = RandomStringUtils.randomAlphanumeric(Certificate.SIZE); + CertifyDto certifyDto = new CertifyDto(email, code); + MockHttpServletRequestBuilder requestBuilder = patch(API_PREFIX + "/certify") + .queryParam("email", certifyDto.email()) + .queryParam("code", certifyDto.code()) + .contentType(MediaType.APPLICATION_JSON); + + // when + ResultActions actions = mockMvc.perform(requestBuilder); + + // then + actions.andExpect((status().isOk())) + .andDo( + document("certify", + getDocumentRequest(), + getDocumentResponse(), + queryParameters( + parameterWithName("email").description("Email 주소"), + parameterWithName("code").description("Email 인증 코드") + ) + ) + ); + } + +} diff --git a/src/test/java/com/backendoori/ootw/user/controller/CertificateControllerTest.java b/src/test/java/com/backendoori/ootw/user/controller/CertificateControllerTest.java index b88f2f68..5698ce60 100644 --- a/src/test/java/com/backendoori/ootw/user/controller/CertificateControllerTest.java +++ b/src/test/java/com/backendoori/ootw/user/controller/CertificateControllerTest.java @@ -66,7 +66,7 @@ void ok() throws Exception { // given MockHttpServletRequestBuilder requestBuilder = patch("/api/v1/auth/certificate") .with(csrf()) - .param("email", sendCodeDto.email()) + .queryParam("email", sendCodeDto.email()) .contentType(MediaType.APPLICATION_JSON); // when @@ -82,7 +82,7 @@ void alreadyReported() throws Exception { // given MockHttpServletRequestBuilder requestBuilder = patch("/api/v1/auth/certificate") .with(csrf()) - .param("email", sendCodeDto.email()) + .queryParam("email", sendCodeDto.email()) .contentType(MediaType.APPLICATION_JSON); doThrow(AlreadyCertifiedUserException.class) @@ -104,7 +104,7 @@ void badRequest(String email) throws Exception { // given MockHttpServletRequestBuilder requestBuilder = patch("/api/v1/auth/certificate") .with(csrf()) - .param("email", email) + .queryParam("email", email) .contentType(MediaType.APPLICATION_JSON); // when @@ -152,8 +152,8 @@ void ok() throws Exception { // given MockHttpServletRequestBuilder requestBuilder = patch("/api/v1/auth/certify") .with(csrf()) - .param("email", certifyDto.email()) - .param("code", certifyDto.code()) + .queryParam("email", certifyDto.email()) + .queryParam("code", certifyDto.code()) .contentType(MediaType.APPLICATION_JSON); // when @@ -169,8 +169,8 @@ void notFound() throws Exception { // given MockHttpServletRequestBuilder requestBuilder = patch("/api/v1/auth/certify") .with(csrf()) - .param("email", certifyDto.email()) - .param("code", certifyDto.code()) + .queryParam("email", certifyDto.email()) + .queryParam("code", certifyDto.code()) .contentType(MediaType.APPLICATION_JSON); doThrow(UserNotFoundException.class) @@ -190,8 +190,8 @@ void alreadyReported() throws Exception { // given MockHttpServletRequestBuilder requestBuilder = patch("/api/v1/auth/certify") .with(csrf()) - .param("email", certifyDto.email()) - .param("code", certifyDto.code()) + .queryParam("email", certifyDto.email()) + .queryParam("code", certifyDto.code()) .contentType(MediaType.APPLICATION_JSON); doThrow(AlreadyCertifiedUserException.class) @@ -211,8 +211,8 @@ void unauthorized() throws Exception { // given MockHttpServletRequestBuilder requestBuilder = patch("/api/v1/auth/certify") .with(csrf()) - .param("email", certifyDto.email()) - .param("code", certifyDto.code()) + .queryParam("email", certifyDto.email()) + .queryParam("code", certifyDto.code()) .contentType(MediaType.APPLICATION_JSON); doThrow(IncorrectCertificateException.class) From 4a128c4ae17a4cd7ff8aa2d2edb4868b1031372f Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 02:20:05 +0900 Subject: [PATCH 06/32] =?UTF-8?q?docs:=20certificate=20api=20docs=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 41 ++++++++++++++++++++++++++++++++---- src/docs/asciidoc/index.html | 30 +++++++++++++------------- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index fd7b020d..ecebf4db 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -14,7 +14,7 @@ Doc Writers - 김현우 = User API ''' -== 회원가입 +== signup NOTE: 사용자 회원가입 @@ -29,13 +29,11 @@ include::{snippets}/user-signup/http-request.adoc[] === Response -include::{snippets}/user-signup/response-body.adoc[] - ==== Response example include::{snippets}/user-signup/http-response.adoc[] -== 로그인 +== login NOTE: 사용자 로그인 @@ -57,3 +55,38 @@ include::{snippets}/user-login/response-fields.adoc[] include::{snippets}/user-login/http-response.adoc[] +== certficate + +NOTE: 이메일 인증 코드 발송 + +=== Request + +include::{snippets}/certificate/query-parameters.adoc[] + +==== Request example + +include::{snippets}/certificate/http-request.adoc[] + +=== Response + +==== Response example + +include::{snippets}/certificate/http-response.adoc[] + +== certify + +NOTE: 이메일 인증 + +=== Request + +include::{snippets}/certify/query-parameters.adoc[] + +==== Request example + +include::{snippets}/certify/http-request.adoc[] + +=== Response + +==== Response example + +include::{snippets}/certify/http-response.adoc[] diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index cc2b7d8f..b626a4ea 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -495,9 +495,9 @@

Request

{
-  "email" : "rich.bailey@hotmail.com",
-  "password" : "xhxC%&6n6&U75X&b!3#00c612d",
-  "nickname" : "vernice.hauck"
+  "email" : "berry.keebler@yahoo.com",
+  "password" : "o4tY8oJNB%",
+  "nickname" : "trevor.wisozk"
 }
@@ -538,13 +538,13 @@

Request examp
POST /api/v1/auth/signup HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Content-Length: 118
+Content-Length: 102
 Host: docs.api.com
 
 {
-  "email" : "rich.bailey@hotmail.com",
-  "password" : "xhxC%&6n6&U75X&b!3#00c612d",
-  "nickname" : "vernice.hauck"
+  "email" : "berry.keebler@yahoo.com",
+  "password" : "o4tY8oJNB%",
+  "nickname" : "trevor.wisozk"
 }
@@ -591,8 +591,8 @@

Request

{
-  "email" : "esteban.lebsack@hotmail.com",
-  "password" : "w9Y$&udGt!*Qk!T1L*7G^H^"
+  "email" : "latoyia.pouros@yahoo.com",
+  "password" : "R0F2mN*9nZ$T%"
 }
@@ -628,12 +628,12 @@

Request e
POST /api/v1/auth/login HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Content-Length: 87
+Content-Length: 74
 Host: docs.api.com
 
 {
-  "email" : "esteban.lebsack@hotmail.com",
-  "password" : "w9Y$&udGt!*Qk!T1L*7G^H^"
+  "email" : "latoyia.pouros@yahoo.com",
+  "password" : "R0F2mN*9nZ$T%"
 }
@@ -644,7 +644,7 @@

Response

{
-  "token" : "625f2b57df80357c94b85153ec3cfe788542296a567156caf8d2305b572c56b998028223e12f377867edfa564ae674cae2004b3d25a5e5f92c58d3822ae58782"
+  "token" : "c5b16b0186f6b7adbd13b6f05058726855011541dbc931afde20e8c17041aa3d76de4b6595459f74c6b39f80624c016c3bdccc6765ab3e1ad62737c0b4920c23"
 }
@@ -677,12 +677,12 @@

Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer 625f2b57df80357c94b85153ec3cfe788542296a567156caf8d2305b572c56b998028223e12f377867edfa564ae674cae2004b3d25a5e5f92c58d3822ae58782 +Authorization: Bearer c5b16b0186f6b7adbd13b6f05058726855011541dbc931afde20e8c17041aa3d76de4b6595459f74c6b39f80624c016c3bdccc6765ab3e1ad62737c0b4920c23 Content-Type: application/json Content-Length: 146 { - "token" : "625f2b57df80357c94b85153ec3cfe788542296a567156caf8d2305b572c56b998028223e12f377867edfa564ae674cae2004b3d25a5e5f92c58d3822ae58782" + "token" : "c5b16b0186f6b7adbd13b6f05058726855011541dbc931afde20e8c17041aa3d76de4b6595459f74c6b39f80624c016c3bdccc6765ab3e1ad62737c0b4920c23" } From 0fc98441f3ccbd6f231863472593bfce5043026c Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 03:17:36 +0900 Subject: [PATCH 07/32] =?UTF-8?q?test:=20avatar=20image=20documentation=20?= =?UTF-8?q?test=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avatar/AvatarItemDocumentationTest.java | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java diff --git a/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java new file mode 100644 index 00000000..7fc3d52d --- /dev/null +++ b/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java @@ -0,0 +1,144 @@ +package com.backendoori.ootw.document.avatar; + +import static com.backendoori.ootw.document.common.ApiDocumentUtil.field; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentRequest; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentResponse; +import static org.mockito.BDDMockito.given; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestPartFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.partWithName; +import static org.springframework.restdocs.request.RequestDocumentation.requestParts; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.nio.charset.StandardCharsets; +import java.util.List; +import com.backendoori.ootw.avatar.domain.ItemType; +import com.backendoori.ootw.avatar.domain.Sex; +import com.backendoori.ootw.avatar.dto.AvatarItemRequest; +import com.backendoori.ootw.avatar.dto.AvatarItemResponse; +import com.backendoori.ootw.avatar.service.AvatarItemService; +import com.fasterxml.jackson.databind.ObjectMapper; +import net.datafaker.Faker; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; + +@WithMockUser +@SpringBootTest +@AutoConfigureMockMvc +@AutoConfigureRestDocs +class AvatarItemDocumentationTest { + + static final Faker FAKER = new Faker(); + static final String API = "/api/v1/avatar-items"; + + @Autowired + MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + + @MockBean + AvatarItemService avatarItemService; + + @DisplayName("[POST] upload 201 Created") + @Test + public void testUploadCreated() throws Exception { + // given + MockMultipartFile file = new MockMultipartFile("file", "filename.txt", + "image/jpeg", "some xml".getBytes()); + AvatarItemRequest requestDto = new AvatarItemRequest("HAIR", Sex.MALE.name()); + MockMultipartFile request = new MockMultipartFile("request", "filename.txt", + "application/json", objectMapper.writeValueAsBytes(requestDto)); + AvatarItemResponse avatarItemResponse = + new AvatarItemResponse((long) FAKER.number().positive(), requestDto.type(), requestDto.sex(), + FAKER.internet().url()); + + given(avatarItemService.upload(file, requestDto)) + .willReturn(avatarItemResponse); + + // when + ResultActions actions = mockMvc.perform(multipart(API) + .file(file) + .file(request) + .contentType(MediaType.MULTIPART_FORM_DATA) + .accept(MediaType.APPLICATION_JSON) + .characterEncoding(StandardCharsets.UTF_8)); + + // then + actions.andExpect(status().isCreated()) + .andDo( + document("avatar-image-upload", + getDocumentRequest(), + getDocumentResponse(), +// TODO: 해당 API가 토큰이 필요 없는지 논의 필요 +// requestHeaders( +// headerWithName("Authorization").description("JWT 토큰") +// ), + requestParts( + partWithName("file").description("아바타 이미지 파일"), + partWithName("request").description("아바타 이미지 상세 정보") + ), + requestPartFields( + "request", + fieldWithPath("type").description("아바타 이미지 타입"), + fieldWithPath("sex").description("아바타 이미지 성별") + ), + responseFields( + field("avatarItemId", JsonFieldType.NUMBER, "아바타 이미지 ID"), + field("type", JsonFieldType.STRING, "아바타 이미지 타입"), + field("sex", JsonFieldType.STRING, "아바타 이미지 성별"), + field("url", JsonFieldType.STRING, "아바타 이미지 URL") + ) + ) + ); + } + + @DisplayName("[POST] getAll 200 Ok") + @Test + public void testGetAllOk() throws Exception { + // given + given(avatarItemService.getList()) + .willReturn(List.of( + new AvatarItemResponse(1L, ItemType.HAIR.name(), Sex.MALE.name(), FAKER.internet().url()), + new AvatarItemResponse(2L, ItemType.TOP.name(), Sex.FEMALE.name(), FAKER.internet().url()) + )); + + // when + ResultActions actions = mockMvc.perform(get(API) + .accept(MediaType.APPLICATION_JSON)); + + // then + actions.andExpect(status().isOk()) + .andDo( + document("avatar-image-get-all", + getDocumentRequest(), + getDocumentResponse(), +// TODO: 해당 API가 토큰이 필요 없는지 논의 필요 +// requestHeaders( +// headerWithName("Authorization").description("JWT 토큰") +// ), + responseFields( + field("[].avatarItemId", JsonFieldType.NUMBER, "아바타 이미지 ID"), + field("[].type", JsonFieldType.STRING, "아바타 이미지 타입"), + field("[].sex", JsonFieldType.STRING, "아바타 이미지 성별"), + field("[].url", JsonFieldType.STRING, "아바타 이미지 URL") + ) + ) + ); + } + +} From e28b5bbd95f0f8b7461cfa56382108bebcb62f86 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 03:19:06 +0900 Subject: [PATCH 08/32] =?UTF-8?q?docs:=20avatar=20image=20api=20docs=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 44 ++++ src/docs/asciidoc/index.html | 476 +++++++++++++++++++++++++++++++++-- 2 files changed, 495 insertions(+), 25 deletions(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index ecebf4db..a349fe82 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -90,3 +90,47 @@ include::{snippets}/certify/http-request.adoc[] ==== Response example include::{snippets}/certify/http-response.adoc[] + += Avatar Item API + +''' +== upload + +NOTE: 아바타 이미지 업로드 + +=== Request + +include::{snippets}/avatar-image-upload/request-parts.adoc[] +include::{snippets}/avatar-image-upload/request-part-request-fields.adoc[] + +==== Request example + +include::{snippets}/avatar-image-upload/http-request.adoc[] + +=== Response + +include::{snippets}/avatar-image-upload/response-body.adoc[] +include::{snippets}/avatar-image-upload/response-fields.adoc[] + +==== Response example + +include::{snippets}/avatar-image-upload/http-response.adoc[] + +== getAll + +NOTE: 전체 아바타 이미지 조회 + +=== Request + +==== Request example + +include::{snippets}/avatar-image-get-all/http-request.adoc[] + +=== Response + +include::{snippets}/avatar-image-get-all/response-body.adoc[] +include::{snippets}/avatar-image-get-all/response-fields.adoc[] + +==== Response example + +include::{snippets}/avatar-image-get-all/http-response.adoc[] diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index b626a4ea..0812e200 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -451,18 +451,46 @@

#OOTW API Documentation

@@ -476,7 +504,7 @@

User API<
-

회원가입

+

signup

@@ -495,9 +523,9 @@

Request

{
-  "email" : "berry.keebler@yahoo.com",
-  "password" : "o4tY8oJNB%",
-  "nickname" : "trevor.wisozk"
+  "email" : "nicolette.hills@hotmail.com",
+  "password" : "h4gIJ2laqBPa083Q@!h^#O&&gty2",
+  "nickname" : "reagan.morar"
 }
@@ -538,13 +566,13 @@

Request examp
POST /api/v1/auth/signup HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Content-Length: 102
+Content-Length: 123
 Host: docs.api.com
 
 {
-  "email" : "berry.keebler@yahoo.com",
-  "password" : "o4tY8oJNB%",
-  "nickname" : "trevor.wisozk"
+  "email" : "nicolette.hills@hotmail.com",
+  "password" : "h4gIJ2laqBPa083Q@!h^#O&&gty2",
+  "nickname" : "reagan.morar"
 }
@@ -552,11 +580,6 @@

Request examp

@@ -591,8 +614,8 @@

Request

{
-  "email" : "latoyia.pouros@yahoo.com",
-  "password" : "R0F2mN*9nZ$T%"
+  "email" : "ariane.fadel@gmail.com",
+  "password" : "CBlv4mz93iJ5^9N*rjnp"
 }
@@ -628,12 +651,12 @@

Request e
POST /api/v1/auth/login HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Content-Length: 74
+Content-Length: 79
 Host: docs.api.com
 
 {
-  "email" : "latoyia.pouros@yahoo.com",
-  "password" : "R0F2mN*9nZ$T%"
+  "email" : "ariane.fadel@gmail.com",
+  "password" : "CBlv4mz93iJ5^9N*rjnp"
 }
@@ -644,7 +667,7 @@

Response

{
-  "token" : "c5b16b0186f6b7adbd13b6f05058726855011541dbc931afde20e8c17041aa3d76de4b6595459f74c6b39f80624c016c3bdccc6765ab3e1ad62737c0b4920c23"
+  "token" : "ff2e95123e2e413e06859623378415cfdd3fb3eaddb61473c92fee9d3d10bc6a7f339e890178ff29a6ecaad97de833941555a6090ae955276bb82bcd3ec41fd7"
 }
@@ -677,12 +700,12 @@

Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer c5b16b0186f6b7adbd13b6f05058726855011541dbc931afde20e8c17041aa3d76de4b6595459f74c6b39f80624c016c3bdccc6765ab3e1ad62737c0b4920c23 +Authorization: Bearer ff2e95123e2e413e06859623378415cfdd3fb3eaddb61473c92fee9d3d10bc6a7f339e890178ff29a6ecaad97de833941555a6090ae955276bb82bcd3ec41fd7 Content-Type: application/json Content-Length: 146 { - "token" : "c5b16b0186f6b7adbd13b6f05058726855011541dbc931afde20e8c17041aa3d76de4b6595459f74c6b39f80624c016c3bdccc6765ab3e1ad62737c0b4920c23" + "token" : "ff2e95123e2e413e06859623378415cfdd3fb3eaddb61473c92fee9d3d10bc6a7f339e890178ff29a6ecaad97de833941555a6090ae955276bb82bcd3ec41fd7" } @@ -690,11 +713,414 @@

Respons +

+ + + + +
+ + +이메일 인증 코드 발송 +
+
+
+

Request

+ ++++ + + + + + + + + + + + + +
ParameterDescription

email

Email 주소

+
+

Request example

+
+
+
PATCH /api/v1/auth/certificate?email=anderson.casper@hotmail.com HTTP/1.1
+Content-Type: application/json;charset=UTF-8
+Host: docs.api.com
+
+
+
+
+
+

Response

+
+

Response example

+
+
+
HTTP/1.1 200 OK
+Vary: Origin
+Vary: Access-Control-Request-Method
+Vary: Access-Control-Request-Headers
+
+
+
+
+
+
+
+

certify

+
+
+ + + + + +
+ + +이메일 인증 +
+
+
+

Request

+ ++++ + + + + + + + + + + + + + + + + +
ParameterDescription

email

Email 주소

code

Email 인증 코드

+
+

Request example

+
+
+
PATCH /api/v1/auth/certify?email=jolanda.mayert@example.com&code=EiOu63 HTTP/1.1
+Content-Type: application/json;charset=UTF-8
+Host: docs.api.com
+
+
+
+
+
+

Response

+
+

Response example

+
+
+
HTTP/1.1 200 OK
+Vary: Origin
+Vary: Access-Control-Request-Method
+Vary: Access-Control-Request-Headers
+
+
+
+
+
+
+

Avatar Item API

+
+
+
+
+
+
+

upload

+
+
+ + + + + +
+ + +아바타 이미지 업로드 +
+
+
+

Request

+ ++++ + + + + + + + + + + + + + + + + +
PartDescription

file

아바타 이미지 파일

request

아바타 이미지 상세 정보

+ +++++ + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

type

String

아바타 이미지 타입

sex

String

아바타 이미지 성별

+
+

Request example

+
+
+
POST /api/v1/avatar-items HTTP/1.1
+Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
+Accept: application/json
+Host: docs.api.com
+
+--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
+Content-Disposition: form-data; name=file; filename=filename.txt
+Content-Type: image/jpeg
+
+some xml
+--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
+Content-Disposition: form-data; name=request; filename=filename.txt
+Content-Type: application/json
+
+{"type":"HAIR","sex":"MALE"}
+--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
+
+
+
+
+
+

Response

+
+
+
{
+  "avatarItemId" : 1042498193,
+  "type" : "HAIR",
+  "sex" : "MALE",
+  "url" : "https://www.earle-christiansen.com/soluta#explicabo"
+}
+
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

avatarItemId

Number

아바타 이미지 ID

type

String

아바타 이미지 타입

sex

String

아바타 이미지 성별

url

String

아바타 이미지 URL

+
+

Response example

+
+
+
HTTP/1.1 201 Created
+Vary: Origin
+Vary: Access-Control-Request-Method
+Vary: Access-Control-Request-Headers
+Content-Type: application/json
+Content-Length: 135
+
+{
+  "avatarItemId" : 1042498193,
+  "type" : "HAIR",
+  "sex" : "MALE",
+  "url" : "https://www.earle-christiansen.com/soluta#explicabo"
+}
+
+
+
+
+
+
+
+

getAll

+
+
+ + + + + +
+ + +전체 아바타 이미지 조회 +
+
+
+

Request

+
+

Request example

+
+
+
GET /api/v1/avatar-items HTTP/1.1
+Accept: application/json
+Host: docs.api.com
+
+
+
+
+
+

Response

+
+
+
[ {
+  "avatarItemId" : 1,
+  "type" : "HAIR",
+  "sex" : "MALE",
+  "url" : "http://www.brant-koch.co/ipsum/doloremvelit#error"
+}, {
+  "avatarItemId" : 2,
+  "type" : "TOP",
+  "sex" : "FEMALE",
+  "url" : "https://www.andrea-bashirian.org/?voluptates=ea&aut=dolore"
+} ]
+
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescription

[].avatarItemId

Number

아바타 이미지 ID

[].type

String

아바타 이미지 타입

[].sex

String

아바타 이미지 성별

[].url

String

아바타 이미지 URL

+
+

Response example

+
+
+
HTTP/1.1 200 OK
+Vary: Origin
+Vary: Access-Control-Request-Method
+Vary: Access-Control-Request-Headers
+Content-Type: application/json
+Content-Length: 264
+
+[ {
+  "avatarItemId" : 1,
+  "type" : "HAIR",
+  "sex" : "MALE",
+  "url" : "http://www.brant-koch.co/ipsum/doloremvelit#error"
+}, {
+  "avatarItemId" : 2,
+  "type" : "TOP",
+  "sex" : "FEMALE",
+  "url" : "https://www.andrea-bashirian.org/?voluptates=ea&aut=dolore"
+} ]
+
+
+
+
+
+
From 1d3d4637dd720e6e366c8b4aedbba53ce5a97b59 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 03:28:38 +0900 Subject: [PATCH 09/32] =?UTF-8?q?test:=20avatar=20image=20upload=20test?= =?UTF-8?q?=EC=97=90=20token=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avatar/AvatarItemDocumentationTest.java | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java index 7fc3d52d..12a3a881 100644 --- a/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java @@ -3,7 +3,11 @@ import static com.backendoori.ootw.document.common.ApiDocumentUtil.field; import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentRequest; import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentResponse; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_HEADER; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_PREFIX; import static org.mockito.BDDMockito.given; +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.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.requestPartFields; @@ -21,11 +25,10 @@ import com.backendoori.ootw.avatar.dto.AvatarItemRequest; import com.backendoori.ootw.avatar.dto.AvatarItemResponse; import com.backendoori.ootw.avatar.service.AvatarItemService; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.backendoori.ootw.security.TokenMockMvcTest; import net.datafaker.Faker; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -34,23 +37,17 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; @WithMockUser @SpringBootTest @AutoConfigureMockMvc @AutoConfigureRestDocs -class AvatarItemDocumentationTest { +class AvatarItemDocumentationTest extends TokenMockMvcTest { static final Faker FAKER = new Faker(); static final String API = "/api/v1/avatar-items"; - @Autowired - MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; - @MockBean AvatarItemService avatarItemService; @@ -63,10 +60,11 @@ public void testUploadCreated() throws Exception { AvatarItemRequest requestDto = new AvatarItemRequest("HAIR", Sex.MALE.name()); MockMultipartFile request = new MockMultipartFile("request", "filename.txt", "application/json", objectMapper.writeValueAsBytes(requestDto)); + long userId = FAKER.number().positive(); AvatarItemResponse avatarItemResponse = - new AvatarItemResponse((long) FAKER.number().positive(), requestDto.type(), requestDto.sex(), - FAKER.internet().url()); + new AvatarItemResponse(userId, requestDto.type(), requestDto.sex(), FAKER.internet().url()); + setToken(userId); given(avatarItemService.upload(file, requestDto)) .willReturn(avatarItemResponse); @@ -74,6 +72,7 @@ public void testUploadCreated() throws Exception { ResultActions actions = mockMvc.perform(multipart(API) .file(file) .file(request) + .header(TOKEN_HEADER, TOKEN_PREFIX + token) .contentType(MediaType.MULTIPART_FORM_DATA) .accept(MediaType.APPLICATION_JSON) .characterEncoding(StandardCharsets.UTF_8)); @@ -84,10 +83,9 @@ public void testUploadCreated() throws Exception { document("avatar-image-upload", getDocumentRequest(), getDocumentResponse(), -// TODO: 해당 API가 토큰이 필요 없는지 논의 필요 -// requestHeaders( -// headerWithName("Authorization").description("JWT 토큰") -// ), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), requestParts( partWithName("file").description("아바타 이미지 파일"), partWithName("request").description("아바타 이미지 상세 정보") @@ -127,10 +125,6 @@ public void testGetAllOk() throws Exception { document("avatar-image-get-all", getDocumentRequest(), getDocumentResponse(), -// TODO: 해당 API가 토큰이 필요 없는지 논의 필요 -// requestHeaders( -// headerWithName("Authorization").description("JWT 토큰") -// ), responseFields( field("[].avatarItemId", JsonFieldType.NUMBER, "아바타 이미지 ID"), field("[].type", JsonFieldType.STRING, "아바타 이미지 타입"), From 3607561fdb60a0c9e0d574cb8a5fb35a3287c19e Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 03:29:14 +0900 Subject: [PATCH 10/32] =?UTF-8?q?docs:=20avatar=20image=20upload=20header?= =?UTF-8?q?=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/index.adoc | 1 + src/docs/asciidoc/index.html | 57 ++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index a349fe82..e8a34b5f 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -100,6 +100,7 @@ NOTE: 아바타 이미지 업로드 === Request +include::{snippets}/avatar-image-upload/request-headers.adoc[] include::{snippets}/avatar-image-upload/request-parts.adoc[] include::{snippets}/avatar-image-upload/request-part-request-fields.adoc[] diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index 0812e200..cf24e65f 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -523,9 +523,9 @@

Request

{
-  "email" : "nicolette.hills@hotmail.com",
-  "password" : "h4gIJ2laqBPa083Q@!h^#O&&gty2",
-  "nickname" : "reagan.morar"
+  "email" : "leonie.mcclure@hotmail.com",
+  "password" : "$%3**Am@6*RuHk&*0^@5^",
+  "nickname" : "calandra.lubowitz"
 }
@@ -566,13 +566,13 @@

Request examp
POST /api/v1/auth/signup HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Content-Length: 123
+Content-Length: 120
 Host: docs.api.com
 
 {
-  "email" : "nicolette.hills@hotmail.com",
-  "password" : "h4gIJ2laqBPa083Q@!h^#O&&gty2",
-  "nickname" : "reagan.morar"
+  "email" : "leonie.mcclure@hotmail.com",
+  "password" : "$%3**Am@6*RuHk&*0^@5^",
+  "nickname" : "calandra.lubowitz"
 }
@@ -614,8 +614,8 @@

Request

{
-  "email" : "ariane.fadel@gmail.com",
-  "password" : "CBlv4mz93iJ5^9N*rjnp"
+  "email" : "kasha.kuhn@hotmail.com",
+  "password" : "Qv@Fe^b5"
 }
@@ -651,12 +651,12 @@

Request e
POST /api/v1/auth/login HTTP/1.1
 Content-Type: application/json;charset=UTF-8
-Content-Length: 79
+Content-Length: 67
 Host: docs.api.com
 
 {
-  "email" : "ariane.fadel@gmail.com",
-  "password" : "CBlv4mz93iJ5^9N*rjnp"
+  "email" : "kasha.kuhn@hotmail.com",
+  "password" : "Qv@Fe^b5"
 }
@@ -667,7 +667,7 @@

Response

{
-  "token" : "ff2e95123e2e413e06859623378415cfdd3fb3eaddb61473c92fee9d3d10bc6a7f339e890178ff29a6ecaad97de833941555a6090ae955276bb82bcd3ec41fd7"
+  "token" : "508e0e51bab1000aca3c6d8d1ebf0b169936ad5efd3862f96bf8de9e7dbb2c4688a24801d7fa500c307c055c532cc2967dfc14165a81902fb3227ad942e4a3fe"
 }
@@ -700,12 +700,12 @@

Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer ff2e95123e2e413e06859623378415cfdd3fb3eaddb61473c92fee9d3d10bc6a7f339e890178ff29a6ecaad97de833941555a6090ae955276bb82bcd3ec41fd7 +Authorization: Bearer 508e0e51bab1000aca3c6d8d1ebf0b169936ad5efd3862f96bf8de9e7dbb2c4688a24801d7fa500c307c055c532cc2967dfc14165a81902fb3227ad942e4a3fe Content-Type: application/json Content-Length: 146 { - "token" : "ff2e95123e2e413e06859623378415cfdd3fb3eaddb61473c92fee9d3d10bc6a7f339e890178ff29a6ecaad97de833941555a6090ae955276bb82bcd3ec41fd7" + "token" : "508e0e51bab1000aca3c6d8d1ebf0b169936ad5efd3862f96bf8de9e7dbb2c4688a24801d7fa500c307c055c532cc2967dfc14165a81902fb3227ad942e4a3fe" } @@ -752,7 +752,7 @@

Request

Request example

-
PATCH /api/v1/auth/certificate?email=anderson.casper@hotmail.com HTTP/1.1
+
PATCH /api/v1/auth/certificate?email=chantal.lesch@yahoo.com HTTP/1.1
 Content-Type: application/json;charset=UTF-8
 Host: docs.api.com
@@ -818,7 +818,7 @@

Request

Request example

@@ -1043,12 +1044,12 @@

Response

"avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "http://www.brant-koch.co/ipsum/doloremvelit#error" + "url" : "http://www.colin-huels.co:17279/?et=qui&ullam=dolorem" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.andrea-bashirian.org/?voluptates=ea&aut=dolore" + "url" : "http://www.al-west.biz:47391/?dignissimos=numquam&sed=dolorum#voluptatem" } ]
@@ -1097,18 +1098,18 @@

Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 264 +Content-Length: 282 [ { "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "http://www.brant-koch.co/ipsum/doloremvelit#error" + "url" : "http://www.colin-huels.co:17279/?et=qui&ullam=dolorem" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.andrea-bashirian.org/?voluptates=ea&aut=dolore" + "url" : "http://www.al-west.biz:47391/?dignissimos=numquam&sed=dolorum#voluptatem" } ] @@ -1120,7 +1121,7 @@

Respons From 29c0afd06f9c92be5327d38946b45cf74a5c0fc4 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 04:01:31 +0900 Subject: [PATCH 11/32] style: fix typo --- .../ootw/document/avatar/AvatarItemDocumentationTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java index 12a3a881..15a60c6c 100644 --- a/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/avatar/AvatarItemDocumentationTest.java @@ -30,23 +30,19 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.ResultActions; -@WithMockUser @SpringBootTest -@AutoConfigureMockMvc @AutoConfigureRestDocs class AvatarItemDocumentationTest extends TokenMockMvcTest { - static final Faker FAKER = new Faker(); static final String API = "/api/v1/avatar-items"; + static final Faker FAKER = new Faker(); @MockBean AvatarItemService avatarItemService; @@ -105,7 +101,7 @@ public void testUploadCreated() throws Exception { ); } - @DisplayName("[POST] getAll 200 Ok") + @DisplayName("[GET] getAll 200 Ok") @Test public void testGetAllOk() throws Exception { // given From bc95393085459cb09e1fe7e6829200b5e56a8732 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 04:01:45 +0900 Subject: [PATCH 12/32] =?UTF-8?q?style:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EB=AC=B8=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/backendoori/ootw/like/controller/LikeController.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/backendoori/ootw/like/controller/LikeController.java b/src/main/java/com/backendoori/ootw/like/controller/LikeController.java index ad3a74a6..4f31fd1c 100644 --- a/src/main/java/com/backendoori/ootw/like/controller/LikeController.java +++ b/src/main/java/com/backendoori/ootw/like/controller/LikeController.java @@ -1,16 +1,12 @@ package com.backendoori.ootw.like.controller; -import com.backendoori.ootw.like.dto.controller.LikeRequest; import com.backendoori.ootw.like.dto.controller.LikeResponse; import com.backendoori.ootw.like.service.LikeService; -import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController From a20d57529ec54679d608019f09e8f4969f1bf25b Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 04:02:04 +0900 Subject: [PATCH 13/32] =?UTF-8?q?test:=20post=20like=20documentation=20tes?= =?UTF-8?q?t=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/like/LikeDocumentationTest.java | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/test/java/com/backendoori/ootw/document/like/LikeDocumentationTest.java diff --git a/src/test/java/com/backendoori/ootw/document/like/LikeDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/like/LikeDocumentationTest.java new file mode 100644 index 00000000..8eada55e --- /dev/null +++ b/src/test/java/com/backendoori/ootw/document/like/LikeDocumentationTest.java @@ -0,0 +1,98 @@ +package com.backendoori.ootw.document.like; + +import static com.backendoori.ootw.document.common.ApiDocumentUtil.field; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentRequest; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentResponse; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_HEADER; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_PREFIX; +import static org.mockito.BDDMockito.given; +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.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.backendoori.ootw.like.dto.controller.LikeRequest; +import com.backendoori.ootw.like.dto.controller.LikeResponse; +import com.backendoori.ootw.like.service.LikeService; +import com.backendoori.ootw.security.TokenMockMvcTest; +import com.backendoori.ootw.user.domain.User; +import net.datafaker.Faker; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.test.web.servlet.ResultActions; + + +@SpringBootTest +@AutoConfigureRestDocs +class LikeDocumentationTest extends TokenMockMvcTest { + + static final String API_PREFIX = "/api/v1/posts"; + static final Faker FAKER = new Faker(); + + @MockBean + LikeService likeService; + + + @DisplayName("[POST] pushLike 200 Ok") + @Test + void testPushLikeOk() throws Exception { + // given + User user = generateUser(); + long postId = FAKER.number().positive(); + LikeRequest request = new LikeRequest(postId); + + setToken(user.getId()); + given(likeService.requestLike(user.getId(), postId)) + .willReturn(new LikeResponse((long) FAKER.number().positive(), user.getId(), postId, true)); + + // when + ResultActions actions = mockMvc.perform(post(API_PREFIX + "/" + postId + "/likes") + .header(TOKEN_HEADER, TOKEN_PREFIX + token) + .content(objectMapper.writeValueAsBytes(request)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + ); + + // then + actions.andExpect(status().isOk()) + .andDo( + document("like-push", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), + requestFields( + fieldWithPath("postId").description("게시글 ID") + ), + responseFields( + field("likeId", JsonFieldType.NUMBER, "좋아요 ID"), + field("userId", JsonFieldType.NUMBER, "좋아요를 누른 사용자 ID"), + field("postId", JsonFieldType.NUMBER, "게시글 ID"), + field("status", JsonFieldType.BOOLEAN, "좋아요 여부") + ) + ) + ); + } + + private User generateUser() { + return User.builder() + .id((long) FAKER.number().positive()) + .email(FAKER.internet().emailAddress()) + .password(FAKER.internet().password()) + .nickname(FAKER.internet().username()) + .profileImageUrl(FAKER.internet().url()) + .certified(true) + .build(); + } + +} From 424147092cebeba68a96792294a6389bcf54128c Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 04:04:46 +0900 Subject: [PATCH 14/32] =?UTF-8?q?docs:=20post=20like=20api=20docs=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 30 ++++- src/docs/asciidoc/index.html | 252 ++++++++++++++++++++++++++++++----- 2 files changed, 247 insertions(+), 35 deletions(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index e8a34b5f..897d7284 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -55,7 +55,7 @@ include::{snippets}/user-login/response-fields.adoc[] include::{snippets}/user-login/http-response.adoc[] -== certficate +== certificate NOTE: 이메일 인증 코드 발송 @@ -117,7 +117,7 @@ include::{snippets}/avatar-image-upload/response-fields.adoc[] include::{snippets}/avatar-image-upload/http-response.adoc[] -== getAll +== get all NOTE: 전체 아바타 이미지 조회 @@ -135,3 +135,29 @@ include::{snippets}/avatar-image-get-all/response-fields.adoc[] ==== Response example include::{snippets}/avatar-image-get-all/http-response.adoc[] + += Post API + +''' +== like push + +NOTE: 게시글 좋아요 + +=== Request + +include::{snippets}/like-push/request-headers.adoc[] +include::{snippets}/like-push/request-body.adoc[] +include::{snippets}/like-push/request-fields.adoc[] + +==== Request example + +include::{snippets}/like-push/http-request.adoc[] + +=== Response + +include::{snippets}/like-push/response-body.adoc[] +include::{snippets}/like-push/response-fields.adoc[] + +==== Response example + +include::{snippets}/like-push/http-response.adoc[] diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index cf24e65f..ad9ce4e5 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -463,7 +463,7 @@

#OOTW API Documentation

  • Response
  • -
  • certficate +
  • certificate
  • -
  • getAll +
  • get all
  • +
  • Post API + +
  • @@ -523,9 +533,9 @@

    Request

    {
    -  "email" : "leonie.mcclure@hotmail.com",
    -  "password" : "$%3**Am@6*RuHk&*0^@5^",
    -  "nickname" : "calandra.lubowitz"
    +  "email" : "mariel.gerhold@hotmail.com",
    +  "password" : "dDvrI&*KpZIH7bq54Z",
    +  "nickname" : "jonas.douglas"
     }
    @@ -566,13 +576,13 @@

    Request examp
    POST /api/v1/auth/signup HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 120
    +Content-Length: 113
     Host: docs.api.com
     
     {
    -  "email" : "leonie.mcclure@hotmail.com",
    -  "password" : "$%3**Am@6*RuHk&*0^@5^",
    -  "nickname" : "calandra.lubowitz"
    +  "email" : "mariel.gerhold@hotmail.com",
    +  "password" : "dDvrI&*KpZIH7bq54Z",
    +  "nickname" : "jonas.douglas"
     }
    @@ -614,8 +624,8 @@

    Request

    {
    -  "email" : "kasha.kuhn@hotmail.com",
    -  "password" : "Qv@Fe^b5"
    +  "email" : "marco.cummerata@hotmail.com",
    +  "password" : "LL25L6D$51^6%4r"
     }
    @@ -651,12 +661,12 @@

    Request e
    POST /api/v1/auth/login HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 67
    +Content-Length: 79
     Host: docs.api.com
     
     {
    -  "email" : "kasha.kuhn@hotmail.com",
    -  "password" : "Qv@Fe^b5"
    +  "email" : "marco.cummerata@hotmail.com",
    +  "password" : "LL25L6D$51^6%4r"
     }
    @@ -667,7 +677,7 @@

    Response

    {
    -  "token" : "508e0e51bab1000aca3c6d8d1ebf0b169936ad5efd3862f96bf8de9e7dbb2c4688a24801d7fa500c307c055c532cc2967dfc14165a81902fb3227ad942e4a3fe"
    +  "token" : "26206fd52e2656a9216d93248ee9c698ba5168e60af08f56f9ced0f51c6cde4f65465388e44f5a81e2c18ad58bbeeaee2ef38f2ac98035b588a9dece95886f89"
     }
    @@ -700,12 +710,12 @@

    Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer 508e0e51bab1000aca3c6d8d1ebf0b169936ad5efd3862f96bf8de9e7dbb2c4688a24801d7fa500c307c055c532cc2967dfc14165a81902fb3227ad942e4a3fe +Authorization: Bearer 26206fd52e2656a9216d93248ee9c698ba5168e60af08f56f9ced0f51c6cde4f65465388e44f5a81e2c18ad58bbeeaee2ef38f2ac98035b588a9dece95886f89 Content-Type: application/json Content-Length: 146 { - "token" : "508e0e51bab1000aca3c6d8d1ebf0b169936ad5efd3862f96bf8de9e7dbb2c4688a24801d7fa500c307c055c532cc2967dfc14165a81902fb3227ad942e4a3fe" + "token" : "26206fd52e2656a9216d93248ee9c698ba5168e60af08f56f9ced0f51c6cde4f65465388e44f5a81e2c18ad58bbeeaee2ef38f2ac98035b588a9dece95886f89" } @@ -714,7 +724,7 @@

    Respons
    -

    certficate

    +

    certificate

    @@ -752,7 +762,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certificate?email=chantal.lesch@yahoo.com HTTP/1.1
    +
    PATCH /api/v1/auth/certificate?email=nolan.buckridge@yahoo.com HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -818,7 +828,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certify?email=kristeen.wisoky@example.com&code=qvHyz5 HTTP/1.1
    +
    PATCH /api/v1/auth/certify?email=ivan.kihn@example.com&code=7sOkEn HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -871,6 +881,24 @@

    Request

    + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    + ++++ + + @@ -918,7 +946,7 @@

    Request e @@ -1009,7 +1037,7 @@

    Respons

    Part Description
    @@ -1044,12 +1072,12 @@

    Response

    "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "http://www.colin-huels.co:17279/?et=qui&ullam=dolorem" + "url" : "https://www.dania-kerluke.net:55092/delectus/quimodi?blanditiis=id&quos=voluptatibus#libero" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "http://www.al-west.biz:47391/?dignissimos=numquam&sed=dolorum#voluptatem" + "url" : "http://www.joelle-beer.co/optio/sunt?facilis=labore&corporis=quis" } ] @@ -1098,18 +1126,18 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 282 +Content-Length: 313 [ { "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "http://www.colin-huels.co:17279/?et=qui&ullam=dolorem" + "url" : "https://www.dania-kerluke.net:55092/delectus/quimodi?blanditiis=id&quos=voluptatibus#libero" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "http://www.al-west.biz:47391/?dignissimos=numquam&sed=dolorum#voluptatem" + "url" : "http://www.joelle-beer.co/optio/sunt?facilis=labore&corporis=quis" } ] @@ -1117,11 +1145,169 @@

    Respons +

    Post API

    +
    +
    +
    +
    +
    +
    +

    like push

    +
    +
    +

    + + + + +
    + + +게시글 좋아요 +
    +
    +
    +

    Request

    + ++++ + + + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    +
    +
    +
    {
    +  "postId" : 1180870601
    +}
    +
    +
    + +++++ + + + + + + + + + + + + + + +
    PathTypeDescription

    postId

    Number

    게시글 ID

    +
    +

    Request example

    +
    +
    +
    POST /api/v1/posts/1180870601/likes HTTP/1.1
    +Content-Type: application/json;charset=UTF-8
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTE4MTYyLCJleHAiOjE3MDU1MjE3NjIsInVzZXJfaWQiOjUyMDA2ODU3fQ.101T8KFRKGTtsurENFjnETcbgu1cFrDC3LouxvriFyTUXJJuNpmMBhIGMhhh3R3X99HoCnGxDEzzujnbNKp_eA
    +Accept: application/json
    +Content-Length: 27
    +Host: docs.api.com
    +
    +{
    +  "postId" : 1180870601
    +}
    +
    +
    +
    +
    +
    +

    Response

    +
    +
    +
    {
    +  "likeId" : 1379159855,
    +  "userId" : 52006857,
    +  "postId" : 1180870601,
    +  "status" : true
    +}
    +
    +
    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PathTypeDescription

    likeId

    Number

    좋아요 ID

    userId

    Number

    좋아요를 누른 사용자 ID

    postId

    Number

    게시글 ID

    status

    Boolean

    좋아요 여부

    +
    +

    Response example

    +
    +
    +
    HTTP/1.1 200 OK
    +Vary: Origin
    +Vary: Access-Control-Request-Method
    +Vary: Access-Control-Request-Headers
    +Content-Type: application/json
    +Content-Length: 94
    +
    +{
    +  "likeId" : 1379159855,
    +  "userId" : 52006857,
    +  "postId" : 1180870601,
    +  "status" : true
    +}
    +
    +
    +
    +
    +
    +
    From 87248d8e5c5cb44d1297637ce762884edf5d19e4 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 04:18:03 +0900 Subject: [PATCH 15/32] =?UTF-8?q?test:=20weather=20documentation=20test=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weather/WeatherControllerTest.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/test/java/com/backendoori/ootw/document/weather/WeatherControllerTest.java diff --git a/src/test/java/com/backendoori/ootw/document/weather/WeatherControllerTest.java b/src/test/java/com/backendoori/ootw/document/weather/WeatherControllerTest.java new file mode 100644 index 00000000..9bbb1d30 --- /dev/null +++ b/src/test/java/com/backendoori/ootw/document/weather/WeatherControllerTest.java @@ -0,0 +1,79 @@ +package com.backendoori.ootw.document.weather; + +import static com.backendoori.ootw.document.common.ApiDocumentUtil.field; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentRequest; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentResponse; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_HEADER; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_PREFIX; +import static com.backendoori.ootw.util.provider.ForecastApiCommonRequestSourceProvider.VALID_COORDINATE; +import static com.backendoori.ootw.util.provider.ForecastApiUltraShortResponseSourceProvider.generateWeatherResponse; +import static org.mockito.BDDMockito.given; +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.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.request.RequestDocumentation.queryParameters; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.backendoori.ootw.security.TokenMockMvcTest; +import com.backendoori.ootw.weather.service.WeatherService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.test.web.servlet.ResultActions; + +@SpringBootTest +@AutoConfigureRestDocs +class WeatherControllerTest extends TokenMockMvcTest { + + static final String API = "/api/v1/weather"; + + @MockBean + WeatherService weatherService; + + @DisplayName("[GET] weather 200 Ok") + @Test + void readCurrentWeatherSuccess() throws Exception { + // given + setToken(1); + given(weatherService.getCurrentWeather(VALID_COORDINATE)) + .willReturn(generateWeatherResponse()); + + // when + ResultActions actions = mockMvc.perform(get(API) + .header(TOKEN_HEADER, TOKEN_PREFIX + token) + .param("nx", String.valueOf(VALID_COORDINATE.nx())) + .param("ny", String.valueOf(VALID_COORDINATE.ny())) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)); + + // then + actions.andExpect(status().isOk()) + .andDo( + document("weather", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), + queryParameters( + parameterWithName("nx").description("사용자 X 좌표"), + parameterWithName("ny").description("사용자 Y 좌표") + ), + responseFields( + field("currentDateTime", JsonFieldType.STRING, "현재 시간"), + field("currentTemperature", JsonFieldType.NUMBER, "현재 온도"), + field("sky", JsonFieldType.STRING, "하늘 상태 코드"), + field("pty", JsonFieldType.STRING, "강수 상태 코드") + ) + ) + ); + } + +} From d23d850a16a7b8c87e7ed4e5b3f6cb8ae9c2e9cc Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 04:18:16 +0900 Subject: [PATCH 16/32] =?UTF-8?q?docs:=20weather=20api=20docs=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 25 +++++++++++ src/docs/asciidoc/index.html | 80 ++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 40 deletions(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 897d7284..a74fb0c1 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -161,3 +161,28 @@ include::{snippets}/like-push/response-fields.adoc[] ==== Response example include::{snippets}/like-push/http-response.adoc[] + += Weather API + +''' +== current weather + +NOTE: 현재 기온 조회 + +=== Request + +include::{snippets}/weather/request-headers.adoc[] +include::{snippets}/weather/query-parameters.adoc[] + +==== Request example + +include::{snippets}/weather/http-request.adoc[] + +=== Response + +include::{snippets}/weather/response-body.adoc[] +include::{snippets}/weather/response-fields.adoc[] + +==== Response example + +include::{snippets}/weather/http-response.adoc[] diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index ad9ce4e5..2baa5de1 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -533,9 +533,9 @@

    Request

    {
    -  "email" : "mariel.gerhold@hotmail.com",
    -  "password" : "dDvrI&*KpZIH7bq54Z",
    -  "nickname" : "jonas.douglas"
    +  "email" : "emmett.rutherford@hotmail.com",
    +  "password" : "!0buZ9mlU609DkiuK%Bd*J!",
    +  "nickname" : "geoffrey.runolfsdottir"
     }
    @@ -576,13 +576,13 @@

    Request examp
    POST /api/v1/auth/signup HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 113
    +Content-Length: 130
     Host: docs.api.com
     
     {
    -  "email" : "mariel.gerhold@hotmail.com",
    -  "password" : "dDvrI&*KpZIH7bq54Z",
    -  "nickname" : "jonas.douglas"
    +  "email" : "emmett.rutherford@hotmail.com",
    +  "password" : "!0buZ9mlU609DkiuK%Bd*J!",
    +  "nickname" : "geoffrey.runolfsdottir"
     }
    @@ -624,8 +624,8 @@

    Request

    {
    -  "email" : "marco.cummerata@hotmail.com",
    -  "password" : "LL25L6D$51^6%4r"
    +  "email" : "edmundo.west@hotmail.com",
    +  "password" : "zP5^43^S"
     }
    @@ -661,12 +661,12 @@

    Request e
    POST /api/v1/auth/login HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 79
    +Content-Length: 69
     Host: docs.api.com
     
     {
    -  "email" : "marco.cummerata@hotmail.com",
    -  "password" : "LL25L6D$51^6%4r"
    +  "email" : "edmundo.west@hotmail.com",
    +  "password" : "zP5^43^S"
     }
    @@ -677,7 +677,7 @@

    Response

    {
    -  "token" : "26206fd52e2656a9216d93248ee9c698ba5168e60af08f56f9ced0f51c6cde4f65465388e44f5a81e2c18ad58bbeeaee2ef38f2ac98035b588a9dece95886f89"
    +  "token" : "4a3bd8e83b0f0be53c4972cd9351e70c33fe0163028f9977b7a1c26fcc28336d6442c1688b12f33139d546c7401cc324df7dcf79e1b0faade213e3c2084a6a24"
     }
    @@ -710,12 +710,12 @@

    Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer 26206fd52e2656a9216d93248ee9c698ba5168e60af08f56f9ced0f51c6cde4f65465388e44f5a81e2c18ad58bbeeaee2ef38f2ac98035b588a9dece95886f89 +Authorization: Bearer 4a3bd8e83b0f0be53c4972cd9351e70c33fe0163028f9977b7a1c26fcc28336d6442c1688b12f33139d546c7401cc324df7dcf79e1b0faade213e3c2084a6a24 Content-Type: application/json Content-Length: 146 { - "token" : "26206fd52e2656a9216d93248ee9c698ba5168e60af08f56f9ced0f51c6cde4f65465388e44f5a81e2c18ad58bbeeaee2ef38f2ac98035b588a9dece95886f89" + "token" : "4a3bd8e83b0f0be53c4972cd9351e70c33fe0163028f9977b7a1c26fcc28336d6442c1688b12f33139d546c7401cc324df7dcf79e1b0faade213e3c2084a6a24" } @@ -762,7 +762,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certificate?email=nolan.buckridge@yahoo.com HTTP/1.1
    +
    PATCH /api/v1/auth/certificate?email=robbyn.heathcote@gmail.com HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -828,7 +828,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certify?email=ivan.kihn@example.com&code=7sOkEn HTTP/1.1
    +
    PATCH /api/v1/auth/certify?email=angelo.vandervort@example.com&code=IYwIFk HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -946,7 +946,7 @@

    Request e

    @@ -1072,12 +1072,12 @@

    Response

    "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "https://www.dania-kerluke.net:55092/delectus/quimodi?blanditiis=id&quos=voluptatibus#libero" + "url" : "http://www.jeromy-volkman.org:31172/odit/officia?quo=aspernatur&consequatur=et#rem" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "http://www.joelle-beer.co/optio/sunt?facilis=labore&corporis=quis" + "url" : "https://www.ramon-cummerata.name:41442/inventore?minima=corrupti&rem=nam#voluptas" } ]
    @@ -1126,18 +1126,18 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 313 +Content-Length: 320 [ { "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "https://www.dania-kerluke.net:55092/delectus/quimodi?blanditiis=id&quos=voluptatibus#libero" + "url" : "http://www.jeromy-volkman.org:31172/odit/officia?quo=aspernatur&consequatur=et#rem" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "http://www.joelle-beer.co/optio/sunt?facilis=labore&corporis=quis" + "url" : "https://www.ramon-cummerata.name:41442/inventore?minima=corrupti&rem=nam#voluptas" } ] @@ -1189,7 +1189,7 @@

    Request

    {
    -  "postId" : 1180870601
    +  "postId" : 625186073
     }
    @@ -1218,15 +1218,15 @@

    Request

    Request example

    -
    POST /api/v1/posts/1180870601/likes HTTP/1.1
    +
    POST /api/v1/posts/625186073/likes HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTE4MTYyLCJleHAiOjE3MDU1MjE3NjIsInVzZXJfaWQiOjUyMDA2ODU3fQ.101T8KFRKGTtsurENFjnETcbgu1cFrDC3LouxvriFyTUXJJuNpmMBhIGMhhh3R3X99HoCnGxDEzzujnbNKp_eA
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTE4OTM3LCJleHAiOjE3MDU1MjI1MzcsInVzZXJfaWQiOjE0MzgwOTMwNTF9.kv-Sh9kdyEKOVFZ5vqgVYqXv2qW1UztS8-yTLq5IAC0n9uYi2FRLCB50jjanUGE3hO7bUW4wdbWCeqMBOuqxQg
     Accept: application/json
    -Content-Length: 27
    +Content-Length: 26
     Host: docs.api.com
     
     {
    -  "postId" : 1180870601
    +  "postId" : 625186073
     }
    @@ -1237,9 +1237,9 @@

    Response

    From bc378e73a63f69ab18e27a27b9f8e7097e11561a Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 04:21:41 +0900 Subject: [PATCH 17/32] style: rename weather documentation test class --- ...herControllerTest.java => WeatherDocumentationTest.java} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/test/java/com/backendoori/ootw/document/weather/{WeatherControllerTest.java => WeatherDocumentationTest.java} (95%) diff --git a/src/test/java/com/backendoori/ootw/document/weather/WeatherControllerTest.java b/src/test/java/com/backendoori/ootw/document/weather/WeatherDocumentationTest.java similarity index 95% rename from src/test/java/com/backendoori/ootw/document/weather/WeatherControllerTest.java rename to src/test/java/com/backendoori/ootw/document/weather/WeatherDocumentationTest.java index 9bbb1d30..076e6d84 100644 --- a/src/test/java/com/backendoori/ootw/document/weather/WeatherControllerTest.java +++ b/src/test/java/com/backendoori/ootw/document/weather/WeatherDocumentationTest.java @@ -30,16 +30,16 @@ @SpringBootTest @AutoConfigureRestDocs -class WeatherControllerTest extends TokenMockMvcTest { +class WeatherDocumentationTest extends TokenMockMvcTest { static final String API = "/api/v1/weather"; @MockBean WeatherService weatherService; - @DisplayName("[GET] weather 200 Ok") + @DisplayName("[GET] readCurrentWeather 200 Ok") @Test - void readCurrentWeatherSuccess() throws Exception { + void testReadCurrentWeatherOk() throws Exception { // given setToken(1); given(weatherService.getCurrentWeather(VALID_COORDINATE)) From 90bf6e8e6ff5e4faafd8dbfa4714c276954d769f Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 05:07:26 +0900 Subject: [PATCH 18/32] =?UTF-8?q?test:=20post=20create=20documentation=20t?= =?UTF-8?q?est=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/post/PostDocumentationTest.java | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java diff --git a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java new file mode 100644 index 00000000..93603223 --- /dev/null +++ b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java @@ -0,0 +1,139 @@ +package com.backendoori.ootw.document.post; + +import static com.backendoori.ootw.document.common.ApiDocumentUtil.field; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentRequest; +import static com.backendoori.ootw.document.common.ApiDocumentUtil.getDocumentResponse; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_HEADER; +import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_PREFIX; +import static com.backendoori.ootw.util.provider.ForecastApiCommonRequestSourceProvider.VALID_COORDINATE; +import static org.mockito.BDDMockito.given; +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.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestPartFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.partWithName; +import static org.springframework.restdocs.request.RequestDocumentation.requestParts; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; +import com.backendoori.ootw.post.dto.request.PostSaveRequest; +import com.backendoori.ootw.post.dto.response.PostSaveUpdateResponse; +import com.backendoori.ootw.post.service.PostService; +import com.backendoori.ootw.security.TokenMockMvcTest; +import com.backendoori.ootw.weather.domain.TemperatureArrange; +import com.backendoori.ootw.weather.domain.forecast.ForecastCategory; +import com.backendoori.ootw.weather.dto.TemperatureArrangeDto; +import com.fasterxml.jackson.core.JsonProcessingException; +import net.datafaker.Faker; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.RequestPostProcessor; + +@SpringBootTest +@AutoConfigureRestDocs +class PostDocumentationTest extends TokenMockMvcTest { + + static final String API_PREFIX = "/api/v1/posts"; + static final Faker FAKER = new Faker(); + + @MockBean + PostService postService; + + @DisplayName("[POST] save 201 Created") + @Test + void testSaveCreated() throws Exception { + // given + PostSaveRequest postSaveRequest = + new PostSaveRequest(FAKER.book().title(), FAKER.science().element(), VALID_COORDINATE); + MockMultipartFile request = getRequestJson(postSaveRequest); + MockMultipartFile postImg = getPostImg(); + + setToken(1); + given(postService.save(postSaveRequest, postImg)) + .willReturn(new PostSaveUpdateResponse(1L, postSaveRequest.title(), postSaveRequest.content(), + FAKER.internet().url(), LocalDateTime.now(), LocalDateTime.now(), + TemperatureArrangeDto.from(generateTemperatureArrange()))); + + // when + ResultActions actions = mockMvc.perform(multipart(API_PREFIX) + .file(request) + .file(postImg) + .header(TOKEN_HEADER, TOKEN_PREFIX + token) + .contentType(MediaType.MULTIPART_FORM_DATA) + .accept(MediaType.APPLICATION_JSON) + .characterEncoding(StandardCharsets.UTF_8) + ); + + // then + actions.andExpect(status().isCreated()) + .andDo( + document("post-create", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), + requestParts( + partWithName("request").description("게시글 생성 요청 정보"), + partWithName("postImg").description("게시글 이미지 파일") + ), + requestPartFields( + "request", + fieldWithPath("title").description("게시글 제목"), + fieldWithPath("content").description("게시글 내용"), + fieldWithPath("coordinate.nx").description("사용자 X 좌표"), + fieldWithPath("coordinate.ny").description("사용자 Y 좌표") + ), + responseFields( + field("postId", JsonFieldType.NUMBER, "게시글 ID"), + field("title", JsonFieldType.STRING, "게시글 제목"), + field("content", JsonFieldType.STRING, "게시글 내용"), + field("image", JsonFieldType.STRING, "게시글 이미지 URL"), + field("createdAt", JsonFieldType.STRING, "게시글 생성 일자"), + field("updatedAt", JsonFieldType.STRING, "게시글 수정 일자"), + field("temperatureArrange.min", JsonFieldType.NUMBER, "최저 기온"), + field("temperatureArrange.max", JsonFieldType.NUMBER, "최고 기온") + ) + ) + ); + } + + private static TemperatureArrange generateTemperatureArrange() { + Map weatherInfoMap = new HashMap<>(); + weatherInfoMap.put(ForecastCategory.TMN, String.valueOf(0.0)); + weatherInfoMap.put(ForecastCategory.TMX, String.valueOf(15.0)); + + return TemperatureArrange.from(weatherInfoMap); + } + + private MockMultipartFile getRequestJson(PostSaveRequest postSaveRequest) throws JsonProcessingException { + return new MockMultipartFile("request", "request.json", MediaType.APPLICATION_JSON_VALUE, + objectMapper.writeValueAsBytes(postSaveRequest)); + } + + private MockMultipartFile getPostImg() { + return new MockMultipartFile("postImg", "image.jpeg", MediaType.IMAGE_JPEG_VALUE, "content".getBytes()); + } + + private RequestPostProcessor setMethod(String method) { + return req -> { + req.setMethod(method); + + return req; + }; + } + +} From 37bfa28fbae649b9f69651384b790037cdcecc04 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 05:48:35 +0900 Subject: [PATCH 19/32] =?UTF-8?q?test:=20post=20read=20detail=20documentat?= =?UTF-8?q?ion=20test=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/post/PostDocumentationTest.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java index 93603223..17a98b7a 100644 --- a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java @@ -10,10 +10,13 @@ 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.get; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.requestPartFields; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.partWithName; +import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParts; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -23,7 +26,9 @@ import java.util.HashMap; import java.util.Map; import com.backendoori.ootw.post.dto.request.PostSaveRequest; +import com.backendoori.ootw.post.dto.response.PostReadResponse; import com.backendoori.ootw.post.dto.response.PostSaveUpdateResponse; +import com.backendoori.ootw.post.dto.response.WriterDto; import com.backendoori.ootw.post.service.PostService; import com.backendoori.ootw.security.TokenMockMvcTest; import com.backendoori.ootw.weather.domain.TemperatureArrange; @@ -111,6 +116,62 @@ void testSaveCreated() throws Exception { ); } + @DisplayName("[GET] readDetailByPostId 200 Ok") + @Test + void testReadDetailByPostIdOk() throws Exception { + // given + long postId = FAKER.number().positive(); + + setToken(1); + given(postService.getDetailByPostId(postId)) + .willReturn(generatePostReadResponse(postId)); + + // when + ResultActions actions = mockMvc.perform(get(API_PREFIX + "/{postId}", postId) + .header(TOKEN_HEADER, TOKEN_PREFIX + token) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + ); + + // then + actions.andExpect(status().isOk()) + .andDo( + document("post-read-detail", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), + pathParameters( + parameterWithName("postId").description("게시글 ID") + ), + responseFields( + field("postId", JsonFieldType.NUMBER, "게시글 ID"), + field("writer.userId", JsonFieldType.NUMBER, "게시글 작성자 ID"), + field("writer.nickname", JsonFieldType.STRING, "게시글 작성자 별명"), + field("writer.image", JsonFieldType.STRING, "게시글 작성자 프로필 이미지 URL"), + field("title", JsonFieldType.STRING, "게시글 제목"), + field("content", JsonFieldType.STRING, "게시글 내용"), + field("image", JsonFieldType.STRING, "게시글 이미지 URL"), + field("createdAt", JsonFieldType.STRING, "게시글 생성 일자"), + field("updatedAt", JsonFieldType.STRING, "게시글 수정 일자"), + field("temperatureArrange.min", JsonFieldType.NUMBER, "최저 기온"), + field("temperatureArrange.max", JsonFieldType.NUMBER, "최고 기온"), + field("likeCnt", JsonFieldType.NUMBER, "좋아요 개수"), + field("isLike", JsonFieldType.NUMBER, "좋아요 여부") + ) + ) + ); + } + + private PostReadResponse generatePostReadResponse(long postId) { + return new PostReadResponse(postId, + new WriterDto((long) FAKER.number().positive(), FAKER.internet().username(), FAKER.internet().url()), + FAKER.book().title(), FAKER.science().element(), FAKER.internet().url(), LocalDateTime.now(), + LocalDateTime.now(), TemperatureArrangeDto.from(generateTemperatureArrange()), + FAKER.number().numberBetween(1, 100), FAKER.number().numberBetween(0, 1)); + } + private static TemperatureArrange generateTemperatureArrange() { Map weatherInfoMap = new HashMap<>(); weatherInfoMap.put(ForecastCategory.TMN, String.valueOf(0.0)); From 895ca93ff49cbd3e2473aa5fb100fdbb419b2454 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 05:52:39 +0900 Subject: [PATCH 20/32] =?UTF-8?q?test:=20post=20read=20all=20documentation?= =?UTF-8?q?=20test=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/post/PostDocumentationTest.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java index 17a98b7a..8c62bf58 100644 --- a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java @@ -24,6 +24,7 @@ import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.backendoori.ootw.post.dto.request.PostSaveRequest; import com.backendoori.ootw.post.dto.response.PostReadResponse; @@ -164,6 +165,93 @@ void testReadDetailByPostIdOk() throws Exception { ); } + @DisplayName("[GET] readAll 200 Ok") + @Test + void testReadAllOk() throws Exception { + // given + setToken(1); + given(postService.getAll()) + .willReturn(List.of(generatePostReadResponse(FAKER.number().positive()), + generatePostReadResponse(FAKER.number().positive()), + generatePostReadResponse(FAKER.number().positive()) + )); + + // when + ResultActions actions = mockMvc.perform(get(API_PREFIX) + .header(TOKEN_HEADER, TOKEN_PREFIX + token) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + ); + + // then + actions.andExpect(status().isOk()) + .andDo( + document("post-read-all", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), + responseFields( + field("[]postId", JsonFieldType.NUMBER, "게시글 ID"), + field("[]writer.userId", JsonFieldType.NUMBER, "게시글 작성자 ID"), + field("[]writer.nickname", JsonFieldType.STRING, "게시글 작성자 별명"), + field("[]writer.image", JsonFieldType.STRING, "게시글 작성자 프로필 이미지 URL"), + field("[]title", JsonFieldType.STRING, "게시글 제목"), + field("[]content", JsonFieldType.STRING, "게시글 내용"), + field("[]image", JsonFieldType.STRING, "게시글 이미지 URL"), + field("[]createdAt", JsonFieldType.STRING, "게시글 생성 일자"), + field("[]updatedAt", JsonFieldType.STRING, "게시글 수정 일자"), + field("[]temperatureArrange.min", JsonFieldType.NUMBER, "최저 기온"), + field("[]temperatureArrange.max", JsonFieldType.NUMBER, "최고 기온"), + field("[]likeCnt", JsonFieldType.NUMBER, "좋아요 개수"), + field("[]isLike", JsonFieldType.NUMBER, "좋아요 여부") + ) + ) + ); + } +// +// @DisplayName("[PUT] update 201 Created") +// @Test +// void testUpdateCreated() throws Exception { +// // given +// long postId = FAKER.number().positive(); +// PostSaveRequest postSaveRequest = +// new PostSaveRequest(FAKER.book().title(), FAKER.science().element(), VALID_COORDINATE); +// MockMultipartFile request = getRequestJson(postSaveRequest); +// +// // when +// ResultActions actions = mockMvc.perform(multipart(API_PREFIX + "/" + postId) +// .file(request) +// .header(TOKEN_HEADER, TOKEN_PREFIX + token) +// .accept(MediaType.APPLICATION_JSON) +// .characterEncoding(StandardCharsets.UTF_8) +// .with(setMethod("PUT")) +// ); +// +// // then +// actions.andExpect(status().isCreated()) +// .andDo( +// null +// ); +// } +// +// @DisplayName("[DELETE] delete 204 NoContent") +// @Test +// void testDeleteNoContent() throws Exception { +// // given +// long postId = FAKER.number().positive(); +// +// // when +// ResultActions actions = mockMvc.perform(delete(API_PREFIX + "/" + postId) +// .header(TOKEN_HEADER, TOKEN_PREFIX + token) +// ); +// +// // then +// actions.andExpect(status().isNoContent()) +// .andDo(null); +// } + private PostReadResponse generatePostReadResponse(long postId) { return new PostReadResponse(postId, new WriterDto((long) FAKER.number().positive(), FAKER.internet().username(), FAKER.internet().url()), From 35e65bf65f8b4c7f2c876fdf506ba0695755cd1f Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:21:31 +0900 Subject: [PATCH 21/32] =?UTF-8?q?test:=20post=20update=20documentation=20t?= =?UTF-8?q?est=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/post/PostDocumentationTest.java | 102 ++++++++++++------ 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java index 8c62bf58..f6572f03 100644 --- a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java @@ -6,11 +6,13 @@ import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_HEADER; import static com.backendoori.ootw.security.jwt.JwtAuthenticationFilter.TOKEN_PREFIX; import static com.backendoori.ootw.util.provider.ForecastApiCommonRequestSourceProvider.VALID_COORDINATE; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; 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.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.multipart; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.requestPartFields; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; @@ -18,7 +20,6 @@ import static org.springframework.restdocs.request.RequestDocumentation.partWithName; import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParts; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.nio.charset.StandardCharsets; @@ -27,6 +28,7 @@ import java.util.List; import java.util.Map; import com.backendoori.ootw.post.dto.request.PostSaveRequest; +import com.backendoori.ootw.post.dto.request.PostUpdateRequest; import com.backendoori.ootw.post.dto.response.PostReadResponse; import com.backendoori.ootw.post.dto.response.PostSaveUpdateResponse; import com.backendoori.ootw.post.dto.response.WriterDto; @@ -69,9 +71,7 @@ void testSaveCreated() throws Exception { setToken(1); given(postService.save(postSaveRequest, postImg)) - .willReturn(new PostSaveUpdateResponse(1L, postSaveRequest.title(), postSaveRequest.content(), - FAKER.internet().url(), LocalDateTime.now(), LocalDateTime.now(), - TemperatureArrangeDto.from(generateTemperatureArrange()))); + .willReturn(generatePostSaveUpdateResponse(1L, postSaveRequest.title(), postSaveRequest.content())); // when ResultActions actions = mockMvc.perform(multipart(API_PREFIX) @@ -210,32 +210,64 @@ void testReadAllOk() throws Exception { ) ); } -// -// @DisplayName("[PUT] update 201 Created") -// @Test -// void testUpdateCreated() throws Exception { -// // given -// long postId = FAKER.number().positive(); -// PostSaveRequest postSaveRequest = -// new PostSaveRequest(FAKER.book().title(), FAKER.science().element(), VALID_COORDINATE); -// MockMultipartFile request = getRequestJson(postSaveRequest); -// -// // when -// ResultActions actions = mockMvc.perform(multipart(API_PREFIX + "/" + postId) -// .file(request) -// .header(TOKEN_HEADER, TOKEN_PREFIX + token) -// .accept(MediaType.APPLICATION_JSON) -// .characterEncoding(StandardCharsets.UTF_8) -// .with(setMethod("PUT")) -// ); -// -// // then -// actions.andExpect(status().isCreated()) -// .andDo( -// null -// ); -// } -// + + @DisplayName("[PUT] update 201 Created") + @Test + void testUpdateCreated() throws Exception { + // given + long postId = 2; + PostUpdateRequest postUpdateRequest = + new PostUpdateRequest(FAKER.book().title(), FAKER.science().element()); + MockMultipartFile request = getRequestJson(postUpdateRequest); + + setToken(1); + given(postService.update(any(), any(), any())) + .willReturn(generatePostSaveUpdateResponse(postId, postUpdateRequest.title(), postUpdateRequest.content())); + + // when + ResultActions actions = + mockMvc.perform(multipart(API_PREFIX + "/{postId}", postId) + .file(request) + .header(TOKEN_HEADER, TOKEN_PREFIX + token) + .accept(MediaType.APPLICATION_JSON) + .characterEncoding(StandardCharsets.UTF_8) + .with(setMethod("PUT")) + ); + + // then + actions.andExpect(status().isCreated()) + .andDo( + document("post-update", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), + pathParameters( + parameterWithName("postId").description("게시글 ID") + ), + requestParts( + partWithName("request").description("게시글 생성 요청 정보") + ), + requestPartFields( + "request", + fieldWithPath("title").description("게시글 제목"), + fieldWithPath("content").description("게시글 내용") + ), + responseFields( + field("postId", JsonFieldType.NUMBER, "게시글 ID"), + field("title", JsonFieldType.STRING, "게시글 제목"), + field("content", JsonFieldType.STRING, "게시글 내용"), + field("image", JsonFieldType.STRING, "게시글 이미지 URL"), + field("createdAt", JsonFieldType.STRING, "게시글 생성 일자"), + field("updatedAt", JsonFieldType.STRING, "게시글 수정 일자"), + field("temperatureArrange.min", JsonFieldType.NUMBER, "최저 기온"), + field("temperatureArrange.max", JsonFieldType.NUMBER, "최고 기온") + ) + ) + ); + } + // @DisplayName("[DELETE] delete 204 NoContent") // @Test // void testDeleteNoContent() throws Exception { @@ -273,6 +305,11 @@ private MockMultipartFile getRequestJson(PostSaveRequest postSaveRequest) throws objectMapper.writeValueAsBytes(postSaveRequest)); } + private MockMultipartFile getRequestJson(PostUpdateRequest postUpdateRequest) throws JsonProcessingException { + return new MockMultipartFile("request", "request.json", MediaType.APPLICATION_JSON_VALUE, + objectMapper.writeValueAsBytes(postUpdateRequest)); + } + private MockMultipartFile getPostImg() { return new MockMultipartFile("postImg", "image.jpeg", MediaType.IMAGE_JPEG_VALUE, "content".getBytes()); } @@ -285,4 +322,9 @@ private RequestPostProcessor setMethod(String method) { }; } + private PostSaveUpdateResponse generatePostSaveUpdateResponse(Long postId, String title, String content) { + return new PostSaveUpdateResponse(postId, title, content, FAKER.internet().url(), LocalDateTime.now(), + LocalDateTime.now(), TemperatureArrangeDto.from(generateTemperatureArrange())); + } + } From f248e0e019a3041868c34771ece1af8342e6d289 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:24:09 +0900 Subject: [PATCH 22/32] =?UTF-8?q?test:=20post=20delete=20documentation=20t?= =?UTF-8?q?est=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/post/PostDocumentationTest.java | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java index f6572f03..c2ed527d 100644 --- a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java @@ -11,6 +11,7 @@ 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; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.multipart; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; @@ -268,21 +269,34 @@ void testUpdateCreated() throws Exception { ); } -// @DisplayName("[DELETE] delete 204 NoContent") -// @Test -// void testDeleteNoContent() throws Exception { -// // given -// long postId = FAKER.number().positive(); -// -// // when -// ResultActions actions = mockMvc.perform(delete(API_PREFIX + "/" + postId) -// .header(TOKEN_HEADER, TOKEN_PREFIX + token) -// ); -// -// // then -// actions.andExpect(status().isNoContent()) -// .andDo(null); -// } + @DisplayName("[DELETE] delete 204 NoContent") + @Test + void testDeleteNoContent() throws Exception { + // given + long postId = FAKER.number().positive(); + + setToken(1); + + // when + ResultActions actions = mockMvc.perform(delete(API_PREFIX + "/{postId}", postId) + .header(TOKEN_HEADER, TOKEN_PREFIX + token) + ); + + // then + actions.andExpect(status().isNoContent()) + .andDo( + document("post-delete", + getDocumentRequest(), + getDocumentResponse(), + requestHeaders( + headerWithName("Authorization").description("JWT 토큰") + ), + pathParameters( + parameterWithName("postId").description("게시글 ID") + ) + ) + ); + } private PostReadResponse generatePostReadResponse(long postId) { return new PostReadResponse(postId, From 3d7b0127ce8fb6c0dedd02e06cbf91d5428257ab Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:27:36 +0900 Subject: [PATCH 23/32] =?UTF-8?q?docs:=20post=20create=20api=20docs=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index a74fb0c1..f89fd22d 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -139,6 +139,30 @@ include::{snippets}/avatar-image-get-all/http-response.adoc[] = Post API ''' +== post create + +NOTE: 게시글 생성 + +=== Request + +include::{snippets}/post-create/request-headers.adoc[] +include::{snippets}/post-create/request-body.adoc[] +include::{snippets}/post-create/request-parts.adoc[] +include::{snippets}/post-create/request-part-request-fields.adoc[] + +==== Request example + +include::{snippets}/post-create/http-request.adoc[] + +=== Response + +include::{snippets}/post-create/response-body.adoc[] +include::{snippets}/post-create/response-fields.adoc[] + +==== Response example + +include::{snippets}/post-create/http-response.adoc[] + == like push NOTE: 게시글 좋아요 From c659ea9b4292e54abf91bec0fb22f2cc90a52103 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:30:44 +0900 Subject: [PATCH 24/32] =?UTF-8?q?docs:=20post=20read=20detail=20api=20docs?= =?UTF-8?q?=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/index.adoc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index f89fd22d..d75d257b 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -146,7 +146,6 @@ NOTE: 게시글 생성 === Request include::{snippets}/post-create/request-headers.adoc[] -include::{snippets}/post-create/request-body.adoc[] include::{snippets}/post-create/request-parts.adoc[] include::{snippets}/post-create/request-part-request-fields.adoc[] @@ -163,6 +162,28 @@ include::{snippets}/post-create/response-fields.adoc[] include::{snippets}/post-create/http-response.adoc[] +== post read detail + +NOTE: 게시글 상세 조회 + +=== Request + +include::{snippets}/post-read-detail/request-headers.adoc[] +include::{snippets}/post-read-detail/path-parameters.adoc[] + +==== Request example + +include::{snippets}/post-read-detail/http-request.adoc[] + +=== Response + +include::{snippets}/post-read-detail/response-body.adoc[] +include::{snippets}/post-read-detail/response-fields.adoc[] + +==== Response example + +include::{snippets}/post-read-detail/http-response.adoc[] + == like push NOTE: 게시글 좋아요 From be5e6b6e1e717b82d0aec8629d51c5a3d4f75e5d Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:31:42 +0900 Subject: [PATCH 25/32] =?UTF-8?q?docs:=20post=20read=20all=20api=20docs=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index d75d257b..1cacd87e 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -184,6 +184,27 @@ include::{snippets}/post-read-detail/response-fields.adoc[] include::{snippets}/post-read-detail/http-response.adoc[] +== post read all + +NOTE: 게시글 전체 조회 + +=== Request + +include::{snippets}/post-read-all/request-headers.adoc[] + +==== Request example + +include::{snippets}/post-read-all/http-request.adoc[] + +=== Response + +include::{snippets}/post-read-all/response-body.adoc[] +include::{snippets}/post-read-all/response-fields.adoc[] + +==== Response example + +include::{snippets}/post-read-all/http-response.adoc[] + == like push NOTE: 게시글 좋아요 From c246a2670a869720a90d75302002d2c005f45eb5 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:39:22 +0900 Subject: [PATCH 26/32] =?UTF-8?q?test:=20=EB=88=84=EB=9D=BD=EB=90=9C=20upd?= =?UTF-8?q?ate=20request=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + faker book title이 30자를 초과해서 실패하는 오류 수정 --- .../ootw/document/post/PostDocumentationTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java index c2ed527d..c5d21a50 100644 --- a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java @@ -65,8 +65,10 @@ class PostDocumentationTest extends TokenMockMvcTest { @Test void testSaveCreated() throws Exception { // given + String title = FAKER.book().title(); PostSaveRequest postSaveRequest = - new PostSaveRequest(FAKER.book().title(), FAKER.science().element(), VALID_COORDINATE); + new PostSaveRequest(title.substring(0, Math.min(title.length(), 30)), FAKER.science().element(), + VALID_COORDINATE); MockMultipartFile request = getRequestJson(postSaveRequest); MockMultipartFile postImg = getPostImg(); @@ -217,9 +219,11 @@ void testReadAllOk() throws Exception { void testUpdateCreated() throws Exception { // given long postId = 2; + String title = FAKER.book().title(); PostUpdateRequest postUpdateRequest = - new PostUpdateRequest(FAKER.book().title(), FAKER.science().element()); + new PostUpdateRequest(title.substring(0, Math.min(title.length(), 30)), FAKER.science().element()); MockMultipartFile request = getRequestJson(postUpdateRequest); + MockMultipartFile postImg = getPostImg(); setToken(1); given(postService.update(any(), any(), any())) @@ -229,6 +233,7 @@ void testUpdateCreated() throws Exception { ResultActions actions = mockMvc.perform(multipart(API_PREFIX + "/{postId}", postId) .file(request) + .file(postImg) .header(TOKEN_HEADER, TOKEN_PREFIX + token) .accept(MediaType.APPLICATION_JSON) .characterEncoding(StandardCharsets.UTF_8) @@ -248,7 +253,8 @@ void testUpdateCreated() throws Exception { parameterWithName("postId").description("게시글 ID") ), requestParts( - partWithName("request").description("게시글 생성 요청 정보") + partWithName("request").description("게시글 생성 요청 정보"), + partWithName("postImg").description("게시글 이미지 파일") ), requestPartFields( "request", From 149db1eff82b86208eabca6afc47325efcfd2601 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:39:54 +0900 Subject: [PATCH 27/32] =?UTF-8?q?docs:=20post=20update=20api=20docs=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 1cacd87e..d8e1398f 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -205,6 +205,29 @@ include::{snippets}/post-read-all/response-fields.adoc[] include::{snippets}/post-read-all/http-response.adoc[] +== post update + +NOTE: 게시글 변경 + +=== Request + +include::{snippets}/post-update/request-headers.adoc[] +include::{snippets}/post-update/request-parts.adoc[] +include::{snippets}/post-update/request-part-request-fields.adoc[] + +==== Request example + +include::{snippets}/post-update/http-request.adoc[] + +=== Response + +include::{snippets}/post-update/response-body.adoc[] +include::{snippets}/post-update/response-fields.adoc[] + +==== Response example + +include::{snippets}/post-update/http-response.adoc[] + == like push NOTE: 게시글 좋아요 From 377b8b0dbd3eb0fcbb7806f2c9dd77fd87ec95dd Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:41:53 +0900 Subject: [PATCH 28/32] =?UTF-8?q?docs:=20post=20delete=20documentation=20t?= =?UTF-8?q?est=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/index.adoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index d8e1398f..1a7d1eb4 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -228,6 +228,25 @@ include::{snippets}/post-update/response-fields.adoc[] include::{snippets}/post-update/http-response.adoc[] +== post delete + +NOTE: 게시글 삭제 + +=== Request + +include::{snippets}/post-delete/request-headers.adoc[] +include::{snippets}/post-delete/path-parameters.adoc[] + +==== Request example + +include::{snippets}/post-delete/http-request.adoc[] + +=== Response + +==== Response example + +include::{snippets}/post-delete/http-response.adoc[] + == like push NOTE: 게시글 좋아요 From 6a338288c43cb028d4803863283941e2f984b284 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 06:44:01 +0900 Subject: [PATCH 29/32] =?UTF-8?q?docs:=20ootw=20api=20document=20index=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.html | 1291 ++++++++++++++++++++++++++++++++-- 1 file changed, 1232 insertions(+), 59 deletions(-) diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index 2baa5de1..1e081b20 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -495,12 +495,52 @@

    #OOTW API Documentation

  • Post API +
  • +
  • Weather API +
  • @@ -533,9 +573,9 @@

    Request

    {
    -  "email" : "emmett.rutherford@hotmail.com",
    -  "password" : "!0buZ9mlU609DkiuK%Bd*J!",
    -  "nickname" : "geoffrey.runolfsdottir"
    +  "email" : "mark.flatley@gmail.com",
    +  "password" : "EN&1*0A$5M*1rh8exz@",
    +  "nickname" : "santos.hegmann"
     }
    @@ -576,13 +616,13 @@

    Request examp
    POST /api/v1/auth/signup HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 130
    +Content-Length: 111
     Host: docs.api.com
     
     {
    -  "email" : "emmett.rutherford@hotmail.com",
    -  "password" : "!0buZ9mlU609DkiuK%Bd*J!",
    -  "nickname" : "geoffrey.runolfsdottir"
    +  "email" : "mark.flatley@gmail.com",
    +  "password" : "EN&1*0A$5M*1rh8exz@",
    +  "nickname" : "santos.hegmann"
     }
    @@ -624,8 +664,8 @@

    Request

    {
    -  "email" : "edmundo.west@hotmail.com",
    -  "password" : "zP5^43^S"
    +  "email" : "numbers.morissette@gmail.com",
    +  "password" : "RWs7%Ad01dQoY&!"
     }
    @@ -661,12 +701,12 @@

    Request e
    POST /api/v1/auth/login HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 69
    +Content-Length: 80
     Host: docs.api.com
     
     {
    -  "email" : "edmundo.west@hotmail.com",
    -  "password" : "zP5^43^S"
    +  "email" : "numbers.morissette@gmail.com",
    +  "password" : "RWs7%Ad01dQoY&!"
     }
    @@ -677,7 +717,7 @@

    Response

    {
    -  "token" : "4a3bd8e83b0f0be53c4972cd9351e70c33fe0163028f9977b7a1c26fcc28336d6442c1688b12f33139d546c7401cc324df7dcf79e1b0faade213e3c2084a6a24"
    +  "token" : "93b751eae60b5e5fac3c59c3a5591a54115bf9bbadc66d14539d089832b7f89f2e2e0e7e4eaf128bfa3b23badd24c05fc68b6430eac10ceaffa25c99c70bde82"
     }
    @@ -710,12 +750,12 @@

    Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer 4a3bd8e83b0f0be53c4972cd9351e70c33fe0163028f9977b7a1c26fcc28336d6442c1688b12f33139d546c7401cc324df7dcf79e1b0faade213e3c2084a6a24 +Authorization: Bearer 93b751eae60b5e5fac3c59c3a5591a54115bf9bbadc66d14539d089832b7f89f2e2e0e7e4eaf128bfa3b23badd24c05fc68b6430eac10ceaffa25c99c70bde82 Content-Type: application/json Content-Length: 146 { - "token" : "4a3bd8e83b0f0be53c4972cd9351e70c33fe0163028f9977b7a1c26fcc28336d6442c1688b12f33139d546c7401cc324df7dcf79e1b0faade213e3c2084a6a24" + "token" : "93b751eae60b5e5fac3c59c3a5591a54115bf9bbadc66d14539d089832b7f89f2e2e0e7e4eaf128bfa3b23badd24c05fc68b6430eac10ceaffa25c99c70bde82" } @@ -762,7 +802,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certificate?email=robbyn.heathcote@gmail.com HTTP/1.1
    +
    PATCH /api/v1/auth/certificate?email=bertram.mohr@yahoo.com HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -828,7 +868,7 @@

    Request

    Request example

    @@ -1072,12 +1112,12 @@

    Response

    "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "http://www.jeromy-volkman.org:31172/odit/officia?quo=aspernatur&consequatur=et#rem" + "url" : "https://www.kazuko-kozey.name/ipsum?sed=animi&blanditiis=eos" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.ramon-cummerata.name:41442/inventore?minima=corrupti&rem=nam#voluptas" + "url" : "https://www.cleo-bayer.name/?commodi=perferendis&tempora=veritatis" } ]
    @@ -1126,18 +1166,18 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 320 +Content-Length: 283 [ { "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "http://www.jeromy-volkman.org:31172/odit/officia?quo=aspernatur&consequatur=et#rem" + "url" : "https://www.kazuko-kozey.name/ipsum?sed=animi&blanditiis=eos" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.ramon-cummerata.name:41442/inventore?minima=corrupti&rem=nam#voluptas" + "url" : "https://www.cleo-bayer.name/?commodi=perferendis&tempora=veritatis" } ] @@ -1152,7 +1192,7 @@

    Post API<
    -

    like push

    +

    post create

    @@ -1161,7 +1201,7 @@

    like push

    -게시글 좋아요 +게시글 생성
    @@ -1186,10 +1226,104 @@

    Request

    + ++++ + + + + + + + + + + + + + + + + +
    PartDescription

    request

    게시글 생성 요청 정보

    postImg

    게시글 이미지 파일

    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PathTypeDescription

    title

    String

    게시글 제목

    content

    String

    게시글 내용

    coordinate.nx

    Number

    사용자 X 좌표

    coordinate.ny

    Number

    사용자 Y 좌표

    +
    +

    Request example

    +
    +
    +
    POST /api/v1/posts HTTP/1.1
    +Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +Accept: application/json
    +Host: docs.api.com
    +
    +--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    +Content-Disposition: form-data; name=request; filename=request.json
    +Content-Type: application/json
    +
    +{"title":"The Violent Bear It Away","content":"Flerovium","coordinate":{"nx":50,"ny":127}}
    +--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    +Content-Disposition: form-data; name=postImg; filename=image.jpeg
    +Content-Type: image/jpeg
    +
    +content
    +--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
    +
    +
    +
    +
    +
    +

    Response

    {
    -  "postId" : 625186073
    +  "postId" : 1,
    +  "title" : "The Violent Bear It Away",
    +  "content" : "Flerovium",
    +  "image" : "https://www.valentine-weissnat.net/#assumenda",
    +  "createdAt" : "2024-01-18T06:42:02.984163",
    +  "updatedAt" : "2024-01-18T06:42:02.984169",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  }
     }
    @@ -1212,35 +1346,162 @@

    Request

    Number

    게시글 ID

    + +

    title

    +

    String

    +

    게시글 제목

    + + +

    content

    +

    String

    +

    게시글 내용

    + + +

    image

    +

    String

    +

    게시글 이미지 URL

    + + +

    createdAt

    +

    String

    +

    게시글 생성 일자

    + + +

    updatedAt

    +

    String

    +

    게시글 수정 일자

    + + +

    temperatureArrange.min

    +

    Number

    +

    최저 기온

    + + +

    temperatureArrange.max

    +

    Number

    +

    최고 기온

    +
    -

    Request example

    +

    Response example

    -
    POST /api/v1/posts/625186073/likes HTTP/1.1
    -Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTE4OTM3LCJleHAiOjE3MDU1MjI1MzcsInVzZXJfaWQiOjE0MzgwOTMwNTF9.kv-Sh9kdyEKOVFZ5vqgVYqXv2qW1UztS8-yTLq5IAC0n9uYi2FRLCB50jjanUGE3hO7bUW4wdbWCeqMBOuqxQg
    -Accept: application/json
    -Content-Length: 26
    -Host: docs.api.com
    +
    HTTP/1.1 201 Created
    +Vary: Origin
    +Vary: Access-Control-Request-Method
    +Vary: Access-Control-Request-Headers
    +Location: /api/v1/posts/1
    +Content-Type: application/json
    +Content-Length: 304
     
     {
    -  "postId" : 625186073
    +  "postId" : 1,
    +  "title" : "The Violent Bear It Away",
    +  "content" : "Flerovium",
    +  "image" : "https://www.valentine-weissnat.net/#assumenda",
    +  "createdAt" : "2024-01-18T06:42:02.984163",
    +  "updatedAt" : "2024-01-18T06:42:02.984169",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  }
     }
    +
    +
    +
    +

    post read detail

    +
    +
    + + + + + +
    + + +게시글 상세 조회 +
    +
    -

    Response

    +

    Request

    + ++++ + + + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    + + ++++ + + + + + + + + + + + + +
    Table 1. /api/v1/posts/{postId}
    ParameterDescription

    postId

    게시글 ID

    +
    +

    Request example

    +
    +
    +
    GET /api/v1/posts/1973037052 HTTP/1.1
    +Content-Type: application/json;charset=UTF-8
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +Accept: application/json
    +Host: docs.api.com
    +
    +
    +
    +
    +
    +

    Response

    {
    -  "likeId" : 1771818915,
    -  "userId" : 1438093051,
    -  "postId" : 625186073,
    -  "status" : true
    +  "postId" : 1973037052,
    +  "writer" : {
    +    "userId" : 910177825,
    +    "nickname" : "flora.ebert",
    +    "image" : "https://www.saundra-dickens.info/enim?sapiente=recusandae&exercitationem=at"
    +  },
    +  "title" : "The Heart Is Deceitful Above All Things",
    +  "content" : "Dysprosium",
    +  "image" : "https://www.lavern-stehr.net:20265/",
    +  "createdAt" : "2024-01-18T06:42:02.938596",
    +  "updatedAt" : "2024-01-18T06:42:02.938602",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  },
    +  "likeCnt" : 65,
    +  "isLike" : 0
     }
    @@ -1259,29 +1520,74 @@

    Response

    -

    likeId

    +

    postId

    Number

    -

    좋아요 ID

    +

    게시글 ID

    -

    userId

    +

    writer.userId

    Number

    -

    좋아요를 누른 사용자 ID

    +

    게시글 작성자 ID

    -

    postId

    +

    writer.nickname

    +

    String

    +

    게시글 작성자 별명

    + + +

    writer.image

    +

    String

    +

    게시글 작성자 프로필 이미지 URL

    + + +

    title

    +

    String

    +

    게시글 제목

    + + +

    content

    +

    String

    +

    게시글 내용

    + + +

    image

    +

    String

    +

    게시글 이미지 URL

    + + +

    createdAt

    +

    String

    +

    게시글 생성 일자

    + + +

    updatedAt

    +

    String

    +

    게시글 수정 일자

    + + +

    temperatureArrange.min

    Number

    -

    게시글 ID

    +

    최저 기온

    -

    status

    -

    Boolean

    +

    temperatureArrange.max

    +

    Number

    +

    최고 기온

    + + +

    likeCnt

    +

    Number

    +

    좋아요 개수

    + + +

    isLike

    +

    Number

    좋아요 여부

    +
    +
    +
    +
    +

    post read all

    +
    +
    + + + + + +
    + + +게시글 전체 조회 +
    +
    +
    +

    Request

    + ++++ + + + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    +
    +

    Request example

    +
    +
    +
    GET /api/v1/posts HTTP/1.1
    +Content-Type: application/json;charset=UTF-8
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +Accept: application/json
    +Host: docs.api.com
    +
    +
    +
    +
    +
    +

    Response

    +
    +
    +
    [ {
    +  "postId" : 740190505,
    +  "writer" : {
    +    "userId" : 1745953572,
    +    "nickname" : "emory.keebler",
    +    "image" : "https://www.idella-price.co/dignissimos/quiarchitecto#illum"
    +  },
    +  "title" : "The Heart Is Deceitful Above All Things",
    +  "content" : "Gadolinium",
    +  "image" : "https://www.ethelene-kub.com/libero?neque=dolorum&aut=nam",
    +  "createdAt" : "2024-01-18T06:42:02.885371",
    +  "updatedAt" : "2024-01-18T06:42:02.885379",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  },
    +  "likeCnt" : 57,
    +  "isLike" : 0
    +}, {
    +  "postId" : 599529396,
    +  "writer" : {
    +    "userId" : 748324641,
    +    "nickname" : "roscoe.morissette",
    +    "image" : "http://www.vida-pacocha.com:42098/sit/doloribus?perferendis=officiis&culpa=expedita#eaque"
    +  },
    +  "title" : "Fair Stood the Wind for France",
    +  "content" : "Hassium",
    +  "image" : "http://www.etsuko-schuppe.biz/veritatis?tempora=ipsam&odio=et",
    +  "createdAt" : "2024-01-18T06:42:02.889132",
    +  "updatedAt" : "2024-01-18T06:42:02.889139",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  },
    +  "likeCnt" : 28,
    +  "isLike" : 0
    +}, {
    +  "postId" : 968524295,
    +  "writer" : {
    +    "userId" : 658219627,
    +    "nickname" : "loretta.berge",
    +    "image" : "https://www.victor-shields.com/"
    +  },
    +  "title" : "The Moving Finger",
    +  "content" : "Moscovium",
    +  "image" : "https://www.ashleigh-swift.com:39179/voluptatem/sint?earum=rem&est=et#dolorem",
    +  "createdAt" : "2024-01-18T06:42:02.889404",
    +  "updatedAt" : "2024-01-18T06:42:02.889407",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  },
    +  "likeCnt" : 1,
    +  "isLike" : 0
    +} ]
    +
    +
    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PathTypeDescription

    []postId

    Number

    게시글 ID

    []writer.userId

    Number

    게시글 작성자 ID

    []writer.nickname

    String

    게시글 작성자 별명

    []writer.image

    String

    게시글 작성자 프로필 이미지 URL

    []title

    String

    게시글 제목

    []content

    String

    게시글 내용

    []image

    String

    게시글 이미지 URL

    []createdAt

    String

    게시글 생성 일자

    []updatedAt

    String

    게시글 수정 일자

    []temperatureArrange.min

    Number

    최저 기온

    []temperatureArrange.max

    Number

    최고 기온

    []likeCnt

    Number

    좋아요 개수

    []isLike

    Number

    좋아요 여부

    +
    +

    Response example

    +
    +
    +
    HTTP/1.1 200 OK
    +Vary: Origin
    +Vary: Access-Control-Request-Method
    +Vary: Access-Control-Request-Headers
    +Content-Type: application/json
    +Content-Length: 1593
    +
    +[ {
    +  "postId" : 740190505,
    +  "writer" : {
    +    "userId" : 1745953572,
    +    "nickname" : "emory.keebler",
    +    "image" : "https://www.idella-price.co/dignissimos/quiarchitecto#illum"
    +  },
    +  "title" : "The Heart Is Deceitful Above All Things",
    +  "content" : "Gadolinium",
    +  "image" : "https://www.ethelene-kub.com/libero?neque=dolorum&aut=nam",
    +  "createdAt" : "2024-01-18T06:42:02.885371",
    +  "updatedAt" : "2024-01-18T06:42:02.885379",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  },
    +  "likeCnt" : 57,
    +  "isLike" : 0
    +}, {
    +  "postId" : 599529396,
    +  "writer" : {
    +    "userId" : 748324641,
    +    "nickname" : "roscoe.morissette",
    +    "image" : "http://www.vida-pacocha.com:42098/sit/doloribus?perferendis=officiis&culpa=expedita#eaque"
    +  },
    +  "title" : "Fair Stood the Wind for France",
    +  "content" : "Hassium",
    +  "image" : "http://www.etsuko-schuppe.biz/veritatis?tempora=ipsam&odio=et",
    +  "createdAt" : "2024-01-18T06:42:02.889132",
    +  "updatedAt" : "2024-01-18T06:42:02.889139",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  },
    +  "likeCnt" : 28,
    +  "isLike" : 0
    +}, {
    +  "postId" : 968524295,
    +  "writer" : {
    +    "userId" : 658219627,
    +    "nickname" : "loretta.berge",
    +    "image" : "https://www.victor-shields.com/"
    +  },
    +  "title" : "The Moving Finger",
    +  "content" : "Moscovium",
    +  "image" : "https://www.ashleigh-swift.com:39179/voluptatem/sint?earum=rem&est=et#dolorem",
    +  "createdAt" : "2024-01-18T06:42:02.889404",
    +  "updatedAt" : "2024-01-18T06:42:02.889407",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  },
    +  "likeCnt" : 1,
    +  "isLike" : 0
    +} ]
    +
    +
    +
    +
    +
    +
    +
    +

    post update

    +
    +
    + + + + + +
    + + +게시글 변경 +
    +
    +
    +

    Request

    + ++++ + + + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    + ++++ + + + + + + + + + + + + + + + + +
    PartDescription

    request

    게시글 생성 요청 정보

    postImg

    게시글 이미지 파일

    + +++++ + + + + + + + + + + + + + + + + + + + +
    PathTypeDescription

    title

    String

    게시글 제목

    content

    String

    게시글 내용

    +
    +

    Request example

    +
    +
    +
    PUT /api/v1/posts/2 HTTP/1.1
    +Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIzLCJleHAiOjE3MDU1MzEzMjMsInVzZXJfaWQiOjF9.QLozNKD3CcpTq71tqyfrlPjohCtv-I-moL9HAJsU1WsPyKfXThx_dp23ILjtgzImaOc5dd1_wmARi5ZXamatWw
    +Accept: application/json
    +Host: docs.api.com
    +
    +--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    +Content-Disposition: form-data; name=request; filename=request.json
    +Content-Type: application/json
    +
    +{"title":"Bury My Heart at Wounded Knee","content":"Fermium"}
    +--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    +Content-Disposition: form-data; name=postImg; filename=image.jpeg
    +Content-Type: image/jpeg
    +
    +content
    +--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
    +
    +
    +
    +
    +
    +

    Response

    +
    +
    +
    {
    +  "postId" : 2,
    +  "title" : "Bury My Heart at Wounded Knee",
    +  "content" : "Fermium",
    +  "image" : "https://www.vincenzo-schaefer.com:53404/odio?repudiandae=optio&rerum=vero",
    +  "createdAt" : "2024-01-18T06:42:03.048074",
    +  "updatedAt" : "2024-01-18T06:42:03.048086",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  }
    +}
    +
    +
    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PathTypeDescription

    postId

    Number

    게시글 ID

    title

    String

    게시글 제목

    content

    String

    게시글 내용

    image

    String

    게시글 이미지 URL

    createdAt

    String

    게시글 생성 일자

    updatedAt

    String

    게시글 수정 일자

    temperatureArrange.min

    Number

    최저 기온

    temperatureArrange.max

    Number

    최고 기온

    +
    +

    Response example

    +
    +
    +
    HTTP/1.1 201 Created
    +Vary: Origin
    +Vary: Access-Control-Request-Method
    +Vary: Access-Control-Request-Headers
    +Location: /api/v1/posts/2
    +Content-Type: application/json
    +Content-Length: 335
    +
    +{
    +  "postId" : 2,
    +  "title" : "Bury My Heart at Wounded Knee",
    +  "content" : "Fermium",
    +  "image" : "https://www.vincenzo-schaefer.com:53404/odio?repudiandae=optio&rerum=vero",
    +  "createdAt" : "2024-01-18T06:42:03.048074",
    +  "updatedAt" : "2024-01-18T06:42:03.048086",
    +  "temperatureArrange" : {
    +    "min" : 0.0,
    +    "max" : 15.0
    +  }
    +}
    +
    +
    +
    +
    +
    +
    +
    +

    post delete

    +
    +
    + + + + + +
    + + +게시글 삭제 +
    +
    +
    +

    Request

    + ++++ + + + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    + + ++++ + + + + + + + + + + + + +
    Table 2. /api/v1/posts/{postId}
    ParameterDescription

    postId

    게시글 ID

    +
    +

    Request example

    +
    +
    +
    DELETE /api/v1/posts/2035273566 HTTP/1.1
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +Host: docs.api.com
    +
    +
    +
    +
    +
    +

    Response

    +
    +

    Response example

    +
    +
    +
    HTTP/1.1 204 No Content
    +Vary: Origin
    +Vary: Access-Control-Request-Method
    +Vary: Access-Control-Request-Headers
    +
    +
    +
    +
    +
    +
    +
    +

    like push

    +
    +
    + + + + + +
    + + +게시글 좋아요 +
    +
    +
    +

    Request

    + ++++ + + + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    +
    +
    +
    {
    +  "postId" : 137888770
    +}
    +
    +
    + +++++ + + + + + + + + + + + + + + +
    PathTypeDescription

    postId

    Number

    게시글 ID

    +
    +

    Request example

    +
    +
    +
    POST /api/v1/posts/137888770/likes HTTP/1.1
    +Content-Type: application/json;charset=UTF-8
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIxLCJleHAiOjE3MDU1MzEzMjEsInVzZXJfaWQiOjE5MzEyNDk4Nzh9.XK6bpDvaX4WTu-lY2kMHleiDS4mn-k-_2hjxj81ZvA1gh2ZfqBnZq328Tkk0C5M-G80s0p-TJr0Ek2ayrzuIfw
    +Accept: application/json
    +Content-Length: 26
    +Host: docs.api.com
    +
    +{
    +  "postId" : 137888770
    +}
    +
    +
    +
    +
    +
    +

    Response

    +
    +
    +
    {
    +  "likeId" : 765568031,
    +  "userId" : 1931249878,
    +  "postId" : 137888770,
    +  "status" : true
    +}
    +
    +
    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PathTypeDescription

    likeId

    Number

    좋아요 ID

    userId

    Number

    좋아요를 누른 사용자 ID

    postId

    Number

    게시글 ID

    status

    Boolean

    좋아요 여부

    +
    +

    Response example

    +
    +
    +
    HTTP/1.1 200 OK
    +Vary: Origin
    +Vary: Access-Control-Request-Method
    +Vary: Access-Control-Request-Headers
    +Content-Type: application/json
    +Content-Length: 94
    +
    +{
    +  "likeId" : 765568031,
    +  "userId" : 1931249878,
    +  "postId" : 137888770,
    +  "status" : true
    +}
    +
    +
    +
    +
    +
    +
    +

    Weather API

    +
    +
    +
    +
    +
    +
    +

    current weather

    +
    +
    + + + + + +
    + + +현재 기온 조회 +
    +
    +
    +

    Request

    + ++++ + + + + + + + + + + + + +
    NameDescription

    Authorization

    JWT 토큰

    + ++++ + + + + + + + + + + + + + + + + +
    ParameterDescription

    nx

    사용자 X 좌표

    ny

    사용자 Y 좌표

    +
    +

    Request example

    +
    +
    +
    GET /api/v1/weather?nx=50&ny=127 HTTP/1.1
    +Content-Type: application/json;charset=UTF-8
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzI2LCJleHAiOjE3MDU1MzEzMjYsInVzZXJfaWQiOjF9.L7UTWN2nAIw8HoWHLHqoTJIhaQhDTqnVcxU2SGDzvlJnWRH8ByOFQbQ07g5ypWEvuz7hjzP1yan1sBoF0cHgAQ
    +Accept: application/json
    +Host: docs.api.com
    +
    +
    +
    +
    +
    +

    Response

    +
    +
    +
    {
    +  "currentDateTime" : "2024-01-10T14:05:00",
    +  "currentTemperature" : 0.0,
    +  "sky" : "SUNNY",
    +  "pty" : "RAIN"
    +}
    +
    +
    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PathTypeDescription

    currentDateTime

    String

    현재 시간

    currentTemperature

    Number

    현재 온도

    sky

    String

    하늘 상태 코드

    pty

    String

    강수 상태 코드

    +
    +

    Response example

    +
    +
    +
    HTTP/1.1 200 OK
    +Vary: Origin
    +Vary: Access-Control-Request-Method
    +Vary: Access-Control-Request-Headers
    +Content-Type: application/json
    +Content-Length: 114
    +
    +{
    +  "currentDateTime" : "2024-01-10T14:05:00",
    +  "currentTemperature" : 0.0,
    +  "sky" : "SUNNY",
    +  "pty" : "RAIN"
     }
    @@ -1307,7 +2480,7 @@

    Respons From 3dc67a2a0eb90442de110cb214d564e886637770 Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 14:04:21 +0900 Subject: [PATCH 30/32] =?UTF-8?q?docs:=20=ED=98=84=EC=9E=AC=20=EA=B8=B0?= =?UTF-8?q?=EC=98=A8=20=EC=A1=B0=ED=9A=8C=EB=A5=BC=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EB=82=A0=EC=94=A8=20=EC=A1=B0=ED=9A=8C=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 2 +- src/docs/asciidoc/index.html | 310 +++++++++++++++++------------------ 2 files changed, 156 insertions(+), 156 deletions(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 1a7d1eb4..0ee4eedf 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -275,7 +275,7 @@ include::{snippets}/like-push/http-response.adoc[] ''' == current weather -NOTE: 현재 기온 조회 +NOTE: 현재 날씨 조회 === Request diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index 1e081b20..2291df4e 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -573,9 +573,9 @@

    Request

    {
    -  "email" : "mark.flatley@gmail.com",
    -  "password" : "EN&1*0A$5M*1rh8exz@",
    -  "nickname" : "santos.hegmann"
    +  "email" : "davina.hickle@yahoo.com",
    +  "password" : "3Q#Kd29725$bTcJ^T#$*2",
    +  "nickname" : "daisy.oconnell"
     }
    @@ -616,13 +616,13 @@

    Request examp
    POST /api/v1/auth/signup HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 111
    +Content-Length: 114
     Host: docs.api.com
     
     {
    -  "email" : "mark.flatley@gmail.com",
    -  "password" : "EN&1*0A$5M*1rh8exz@",
    -  "nickname" : "santos.hegmann"
    +  "email" : "davina.hickle@yahoo.com",
    +  "password" : "3Q#Kd29725$bTcJ^T#$*2",
    +  "nickname" : "daisy.oconnell"
     }

    @@ -664,8 +664,8 @@

    Request

    {
    -  "email" : "numbers.morissette@gmail.com",
    -  "password" : "RWs7%Ad01dQoY&!"
    +  "email" : "darrell.murphy@hotmail.com",
    +  "password" : "Fv0V0D15%"
     }
    @@ -701,12 +701,12 @@

    Request e
    POST /api/v1/auth/login HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 80
    +Content-Length: 72
     Host: docs.api.com
     
     {
    -  "email" : "numbers.morissette@gmail.com",
    -  "password" : "RWs7%Ad01dQoY&!"
    +  "email" : "darrell.murphy@hotmail.com",
    +  "password" : "Fv0V0D15%"
     }

    @@ -717,7 +717,7 @@

    Response

    {
    -  "token" : "93b751eae60b5e5fac3c59c3a5591a54115bf9bbadc66d14539d089832b7f89f2e2e0e7e4eaf128bfa3b23badd24c05fc68b6430eac10ceaffa25c99c70bde82"
    +  "token" : "ffa6ef4739d461448c4e21a16cfb0a9ddfc34f51f051b316af7f082f1cde024987d8d345c1317af230451d9d8e3d825ce677d73e74183e3ad5188afa76f1117f"
     }
    @@ -750,12 +750,12 @@

    Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer 93b751eae60b5e5fac3c59c3a5591a54115bf9bbadc66d14539d089832b7f89f2e2e0e7e4eaf128bfa3b23badd24c05fc68b6430eac10ceaffa25c99c70bde82 +Authorization: Bearer ffa6ef4739d461448c4e21a16cfb0a9ddfc34f51f051b316af7f082f1cde024987d8d345c1317af230451d9d8e3d825ce677d73e74183e3ad5188afa76f1117f Content-Type: application/json Content-Length: 146 { - "token" : "93b751eae60b5e5fac3c59c3a5591a54115bf9bbadc66d14539d089832b7f89f2e2e0e7e4eaf128bfa3b23badd24c05fc68b6430eac10ceaffa25c99c70bde82" + "token" : "ffa6ef4739d461448c4e21a16cfb0a9ddfc34f51f051b316af7f082f1cde024987d8d345c1317af230451d9d8e3d825ce677d73e74183e3ad5188afa76f1117f" }

    @@ -802,7 +802,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certificate?email=bertram.mohr@yahoo.com HTTP/1.1
    +
    PATCH /api/v1/auth/certificate?email=boyd.wunsch@yahoo.com HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -868,7 +868,7 @@

    Request

    Request example

    @@ -1112,12 +1112,12 @@

    Response

    "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "https://www.kazuko-kozey.name/ipsum?sed=animi&blanditiis=eos" + "url" : "https://www.nelle-bogisich.co:61111/neque/hicperferendis?nihil=vel&quis=maxime#iste" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.cleo-bayer.name/?commodi=perferendis&tempora=veritatis" + "url" : "https://www.caroyln-howell.org:10354/praesentium" } ]
    @@ -1166,18 +1166,18 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 283 +Content-Length: 288 [ { "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "https://www.kazuko-kozey.name/ipsum?sed=animi&blanditiis=eos" + "url" : "https://www.nelle-bogisich.co:61111/neque/hicperferendis?nihil=vel&quis=maxime#iste" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.cleo-bayer.name/?commodi=perferendis&tempora=veritatis" + "url" : "https://www.caroyln-howell.org:10354/praesentium" } ] @@ -1290,7 +1290,7 @@

    Request e
    POST /api/v1/posts HTTP/1.1
     Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
     Accept: application/json
     Host: docs.api.com
     
    @@ -1298,7 +1298,7 @@ 

    Request e Content-Disposition: form-data; name=request; filename=request.json Content-Type: application/json -{"title":"The Violent Bear It Away","content":"Flerovium","coordinate":{"nx":50,"ny":127}} +{"title":"His Dark Materials","content":"Carbon","coordinate":{"nx":50,"ny":127}} --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm Content-Disposition: form-data; name=postImg; filename=image.jpeg Content-Type: image/jpeg @@ -1315,11 +1315,11 @@

    Response

    {
       "postId" : 1,
    -  "title" : "The Violent Bear It Away",
    -  "content" : "Flerovium",
    -  "image" : "https://www.valentine-weissnat.net/#assumenda",
    -  "createdAt" : "2024-01-18T06:42:02.984163",
    -  "updatedAt" : "2024-01-18T06:42:02.984169",
    +  "title" : "His Dark Materials",
    +  "content" : "Carbon",
    +  "image" : "https://www.macy-buckridge.co:60790/dolorem",
    +  "createdAt" : "2024-01-18T14:03:31.195215",
    +  "updatedAt" : "2024-01-18T14:03:31.195222",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
    @@ -1393,15 +1393,15 @@ 

    Respons Vary: Access-Control-Request-Headers Location: /api/v1/posts/1 Content-Type: application/json -Content-Length: 304 +Content-Length: 293 { "postId" : 1, - "title" : "The Violent Bear It Away", - "content" : "Flerovium", - "image" : "https://www.valentine-weissnat.net/#assumenda", - "createdAt" : "2024-01-18T06:42:02.984163", - "updatedAt" : "2024-01-18T06:42:02.984169", + "title" : "His Dark Materials", + "content" : "Carbon", + "image" : "https://www.macy-buckridge.co:60790/dolorem", + "createdAt" : "2024-01-18T14:03:31.195215", + "updatedAt" : "2024-01-18T14:03:31.195222", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 @@ -1471,9 +1471,9 @@

    Request

    Request example

    -
    GET /api/v1/posts/1973037052 HTTP/1.1
    +
    GET /api/v1/posts/1438852838 HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
     Accept: application/json
     Host: docs.api.com
    @@ -1485,22 +1485,22 @@

    Response

    {
    -  "postId" : 1973037052,
    +  "postId" : 1438852838,
       "writer" : {
    -    "userId" : 910177825,
    -    "nickname" : "flora.ebert",
    -    "image" : "https://www.saundra-dickens.info/enim?sapiente=recusandae&exercitationem=at"
    +    "userId" : 930304021,
    +    "nickname" : "vida.daniel",
    +    "image" : "http://www.rosendo-dietrich.biz/ut/et#harum"
       },
    -  "title" : "The Heart Is Deceitful Above All Things",
    -  "content" : "Dysprosium",
    -  "image" : "https://www.lavern-stehr.net:20265/",
    -  "createdAt" : "2024-01-18T06:42:02.938596",
    -  "updatedAt" : "2024-01-18T06:42:02.938602",
    +  "title" : "For Whom the Bell Tolls",
    +  "content" : "Germanium",
    +  "image" : "https://www.tisa-schimmel.name/corporis/magnam?quaerat=qui&eius=rerum",
    +  "createdAt" : "2024-01-18T14:03:31.152578",
    +  "updatedAt" : "2024-01-18T14:03:31.152586",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 65,
    +  "likeCnt" : 32,
       "isLike" : 0
     }
    @@ -1595,25 +1595,25 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 523 +Content-Length: 508 { - "postId" : 1973037052, + "postId" : 1438852838, "writer" : { - "userId" : 910177825, - "nickname" : "flora.ebert", - "image" : "https://www.saundra-dickens.info/enim?sapiente=recusandae&exercitationem=at" + "userId" : 930304021, + "nickname" : "vida.daniel", + "image" : "http://www.rosendo-dietrich.biz/ut/et#harum" }, - "title" : "The Heart Is Deceitful Above All Things", - "content" : "Dysprosium", - "image" : "https://www.lavern-stehr.net:20265/", - "createdAt" : "2024-01-18T06:42:02.938596", - "updatedAt" : "2024-01-18T06:42:02.938602", + "title" : "For Whom the Bell Tolls", + "content" : "Germanium", + "image" : "https://www.tisa-schimmel.name/corporis/magnam?quaerat=qui&eius=rerum", + "createdAt" : "2024-01-18T14:03:31.152578", + "updatedAt" : "2024-01-18T14:03:31.152586", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 65, + "likeCnt" : 32, "isLike" : 0 }

    @@ -1663,7 +1663,7 @@

    Request e
    GET /api/v1/posts HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
     Accept: application/json
     Host: docs.api.com
    @@ -1675,58 +1675,58 @@

    Response

    [ {
    -  "postId" : 740190505,
    +  "postId" : 1377184747,
       "writer" : {
    -    "userId" : 1745953572,
    -    "nickname" : "emory.keebler",
    -    "image" : "https://www.idella-price.co/dignissimos/quiarchitecto#illum"
    +    "userId" : 2132280395,
    +    "nickname" : "saul.leffler",
    +    "image" : "https://www.jules-douglas.org:55369/rerum#autem"
       },
    -  "title" : "The Heart Is Deceitful Above All Things",
    -  "content" : "Gadolinium",
    -  "image" : "https://www.ethelene-kub.com/libero?neque=dolorum&aut=nam",
    -  "createdAt" : "2024-01-18T06:42:02.885371",
    -  "updatedAt" : "2024-01-18T06:42:02.885379",
    +  "title" : "By Grand Central Station I Sat Down and Wept",
    +  "content" : "Molybdenum",
    +  "image" : "http://www.tamatha-cremin.org:55843/voluptate/velitquibusdam?amet=dicta&in=et",
    +  "createdAt" : "2024-01-18T14:03:31.0926",
    +  "updatedAt" : "2024-01-18T14:03:31.092606",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 57,
    +  "likeCnt" : 3,
       "isLike" : 0
     }, {
    -  "postId" : 599529396,
    +  "postId" : 970591755,
       "writer" : {
    -    "userId" : 748324641,
    -    "nickname" : "roscoe.morissette",
    -    "image" : "http://www.vida-pacocha.com:42098/sit/doloribus?perferendis=officiis&culpa=expedita#eaque"
    +    "userId" : 784295722,
    +    "nickname" : "alton.doyle",
    +    "image" : "https://www.consuelo-pagac.io:34024/qui/dignissimosaccusantium#minus"
       },
    -  "title" : "Fair Stood the Wind for France",
    -  "content" : "Hassium",
    -  "image" : "http://www.etsuko-schuppe.biz/veritatis?tempora=ipsam&odio=et",
    -  "createdAt" : "2024-01-18T06:42:02.889132",
    -  "updatedAt" : "2024-01-18T06:42:02.889139",
    +  "title" : "Ring of Bright Water",
    +  "content" : "Protactinium",
    +  "image" : "https://www.georgiann-jenkins.org/aut/porro?cupiditate=eius&ea=eum#nulla",
    +  "createdAt" : "2024-01-18T14:03:31.094355",
    +  "updatedAt" : "2024-01-18T14:03:31.09436",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 28,
    +  "likeCnt" : 38,
       "isLike" : 0
     }, {
    -  "postId" : 968524295,
    +  "postId" : 126153066,
       "writer" : {
    -    "userId" : 658219627,
    -    "nickname" : "loretta.berge",
    -    "image" : "https://www.victor-shields.com/"
    +    "userId" : 631346244,
    +    "nickname" : "claris.batz",
    +    "image" : "https://www.vaughn-blick.com/nihil/quod#incidunt"
       },
    -  "title" : "The Moving Finger",
    -  "content" : "Moscovium",
    -  "image" : "https://www.ashleigh-swift.com:39179/voluptatem/sint?earum=rem&est=et#dolorem",
    -  "createdAt" : "2024-01-18T06:42:02.889404",
    -  "updatedAt" : "2024-01-18T06:42:02.889407",
    +  "title" : "Nine Coaches Waiting",
    +  "content" : "Tin",
    +  "image" : "https://www.bill-zboncak.info/ut/excepturi?unde=mollitia&dolor=distinctio",
    +  "createdAt" : "2024-01-18T14:03:31.094551",
    +  "updatedAt" : "2024-01-18T14:03:31.094553",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 1,
    +  "likeCnt" : 19,
       "isLike" : 0
     } ]
    @@ -1821,61 +1821,61 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 1593 +Content-Length: 1590 [ { - "postId" : 740190505, + "postId" : 1377184747, "writer" : { - "userId" : 1745953572, - "nickname" : "emory.keebler", - "image" : "https://www.idella-price.co/dignissimos/quiarchitecto#illum" + "userId" : 2132280395, + "nickname" : "saul.leffler", + "image" : "https://www.jules-douglas.org:55369/rerum#autem" }, - "title" : "The Heart Is Deceitful Above All Things", - "content" : "Gadolinium", - "image" : "https://www.ethelene-kub.com/libero?neque=dolorum&aut=nam", - "createdAt" : "2024-01-18T06:42:02.885371", - "updatedAt" : "2024-01-18T06:42:02.885379", + "title" : "By Grand Central Station I Sat Down and Wept", + "content" : "Molybdenum", + "image" : "http://www.tamatha-cremin.org:55843/voluptate/velitquibusdam?amet=dicta&in=et", + "createdAt" : "2024-01-18T14:03:31.0926", + "updatedAt" : "2024-01-18T14:03:31.092606", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 57, + "likeCnt" : 3, "isLike" : 0 }, { - "postId" : 599529396, + "postId" : 970591755, "writer" : { - "userId" : 748324641, - "nickname" : "roscoe.morissette", - "image" : "http://www.vida-pacocha.com:42098/sit/doloribus?perferendis=officiis&culpa=expedita#eaque" + "userId" : 784295722, + "nickname" : "alton.doyle", + "image" : "https://www.consuelo-pagac.io:34024/qui/dignissimosaccusantium#minus" }, - "title" : "Fair Stood the Wind for France", - "content" : "Hassium", - "image" : "http://www.etsuko-schuppe.biz/veritatis?tempora=ipsam&odio=et", - "createdAt" : "2024-01-18T06:42:02.889132", - "updatedAt" : "2024-01-18T06:42:02.889139", + "title" : "Ring of Bright Water", + "content" : "Protactinium", + "image" : "https://www.georgiann-jenkins.org/aut/porro?cupiditate=eius&ea=eum#nulla", + "createdAt" : "2024-01-18T14:03:31.094355", + "updatedAt" : "2024-01-18T14:03:31.09436", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 28, + "likeCnt" : 38, "isLike" : 0 }, { - "postId" : 968524295, + "postId" : 126153066, "writer" : { - "userId" : 658219627, - "nickname" : "loretta.berge", - "image" : "https://www.victor-shields.com/" + "userId" : 631346244, + "nickname" : "claris.batz", + "image" : "https://www.vaughn-blick.com/nihil/quod#incidunt" }, - "title" : "The Moving Finger", - "content" : "Moscovium", - "image" : "https://www.ashleigh-swift.com:39179/voluptatem/sint?earum=rem&est=et#dolorem", - "createdAt" : "2024-01-18T06:42:02.889404", - "updatedAt" : "2024-01-18T06:42:02.889407", + "title" : "Nine Coaches Waiting", + "content" : "Tin", + "image" : "https://www.bill-zboncak.info/ut/excepturi?unde=mollitia&dolor=distinctio", + "createdAt" : "2024-01-18T14:03:31.094551", + "updatedAt" : "2024-01-18T14:03:31.094553", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 1, + "likeCnt" : 19, "isLike" : 0 } ]

    @@ -1973,7 +1973,7 @@

    Request
    PUT /api/v1/posts/2 HTTP/1.1
     Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIzLCJleHAiOjE3MDU1MzEzMjMsInVzZXJfaWQiOjF9.QLozNKD3CcpTq71tqyfrlPjohCtv-I-moL9HAJsU1WsPyKfXThx_dp23ILjtgzImaOc5dd1_wmARi5ZXamatWw
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
     Accept: application/json
     Host: docs.api.com
     
    @@ -1981,7 +1981,7 @@ 

    Request Content-Disposition: form-data; name=request; filename=request.json Content-Type: application/json -{"title":"Bury My Heart at Wounded Knee","content":"Fermium"} +{"title":"The Wives of Bath","content":"Erbium"} --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm Content-Disposition: form-data; name=postImg; filename=image.jpeg Content-Type: image/jpeg @@ -1998,11 +1998,11 @@

    Response

    {
       "postId" : 2,
    -  "title" : "Bury My Heart at Wounded Knee",
    -  "content" : "Fermium",
    -  "image" : "https://www.vincenzo-schaefer.com:53404/odio?repudiandae=optio&rerum=vero",
    -  "createdAt" : "2024-01-18T06:42:03.048074",
    -  "updatedAt" : "2024-01-18T06:42:03.048086",
    +  "title" : "The Wives of Bath",
    +  "content" : "Erbium",
    +  "image" : "https://www.claud-huels.biz/",
    +  "createdAt" : "2024-01-18T14:03:31.255841",
    +  "updatedAt" : "2024-01-18T14:03:31.255869",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
    @@ -2076,15 +2076,15 @@ 

    Respo Vary: Access-Control-Request-Headers Location: /api/v1/posts/2 Content-Type: application/json -Content-Length: 335 +Content-Length: 277 { "postId" : 2, - "title" : "Bury My Heart at Wounded Knee", - "content" : "Fermium", - "image" : "https://www.vincenzo-schaefer.com:53404/odio?repudiandae=optio&rerum=vero", - "createdAt" : "2024-01-18T06:42:03.048074", - "updatedAt" : "2024-01-18T06:42:03.048086", + "title" : "The Wives of Bath", + "content" : "Erbium", + "image" : "https://www.claud-huels.biz/", + "createdAt" : "2024-01-18T14:03:31.255841", + "updatedAt" : "2024-01-18T14:03:31.255869", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 @@ -2154,8 +2154,8 @@

    Request

    Request example

    -
    DELETE /api/v1/posts/2035273566 HTTP/1.1
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIyLCJleHAiOjE3MDU1MzEzMjIsInVzZXJfaWQiOjF9.2FZL3vdSM9P-uhi2bTSn6PzdnLlBUs01FL0yk3R4phbSHb2JRCBTr1PofRUASIHUTKb3vrgAD4kRmetr7ilCFw
    +
    DELETE /api/v1/posts/1570303977 HTTP/1.1
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
     Host: docs.api.com
    @@ -2215,7 +2215,7 @@

    Request

    {
    -  "postId" : 137888770
    +  "postId" : 1698117767
     }
    @@ -2244,15 +2244,15 @@

    Request

    Request example

    -
    POST /api/v1/posts/137888770/likes HTTP/1.1
    +
    POST /api/v1/posts/1698117767/likes HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzIxLCJleHAiOjE3MDU1MzEzMjEsInVzZXJfaWQiOjE5MzEyNDk4Nzh9.XK6bpDvaX4WTu-lY2kMHleiDS4mn-k-_2hjxj81ZvA1gh2ZfqBnZq328Tkk0C5M-G80s0p-TJr0Ek2ayrzuIfw
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjA5LCJleHAiOjE3MDU1NTc4MDksInVzZXJfaWQiOjEzODAzNjQ2ODd9.avTFFTmbr4VEjYkHmehAvEXvNP4GGrX-mKzBWq5Nxidiphvpmx0QBvPyU2PmheLGYGZKEiqLFwAwPGqT1SLakA
     Accept: application/json
    -Content-Length: 26
    +Content-Length: 27
     Host: docs.api.com
     
     {
    -  "postId" : 137888770
    +  "postId" : 1698117767
     }
    @@ -2263,9 +2263,9 @@

    Response

    @@ -2345,7 +2345,7 @@

    current weath -현재 기온 조회 +현재 날씨 조회 @@ -2398,7 +2398,7 @@

    Request
    GET /api/v1/weather?nx=50&ny=127 HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTI3NzI2LCJleHAiOjE3MDU1MzEzMjYsInVzZXJfaWQiOjF9.L7UTWN2nAIw8HoWHLHqoTJIhaQhDTqnVcxU2SGDzvlJnWRH8ByOFQbQ07g5ypWEvuz7hjzP1yan1sBoF0cHgAQ
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjE0LCJleHAiOjE3MDU1NTc4MTQsInVzZXJfaWQiOjF9.aIpCeqrSrBPcYGc29tSrDQ2Jka7FQuu0RcfVE9XZQu3swBzZjBXajl0-NWWsTZhdE-QhiRTa-eRPt4nx8bsnPw
     Accept: application/json
     Host: docs.api.com
    @@ -2480,7 +2480,7 @@

    Respo From 049cfa1809ccbd1e6060679d4c8f6a60e1bd45fb Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 18:44:27 +0900 Subject: [PATCH 31/32] test: set post read token header to optional --- .../backendoori/ootw/document/post/PostDocumentationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java index c5d21a50..cea8baca 100644 --- a/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java +++ b/src/test/java/com/backendoori/ootw/document/post/PostDocumentationTest.java @@ -144,7 +144,7 @@ void testReadDetailByPostIdOk() throws Exception { getDocumentRequest(), getDocumentResponse(), requestHeaders( - headerWithName("Authorization").description("JWT 토큰") + headerWithName("Authorization").description("JWT 토큰").optional() ), pathParameters( parameterWithName("postId").description("게시글 ID") @@ -193,7 +193,7 @@ void testReadAllOk() throws Exception { getDocumentRequest(), getDocumentResponse(), requestHeaders( - headerWithName("Authorization").description("JWT 토큰") + headerWithName("Authorization").description("JWT 토큰").optional() ), responseFields( field("[]postId", JsonFieldType.NUMBER, "게시글 ID"), From 45448b3b3fe27273a8dcbe4054a04d907dedd48b Mon Sep 17 00:00:00 2001 From: ASak1104 Date: Thu, 18 Jan 2024 18:44:51 +0900 Subject: [PATCH 32/32] =?UTF-8?q?docs:=20token=20header=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=9C=20optional=20=EC=BB=AC=EB=9F=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.html | 384 ++++++++++-------- .../asciidoctor/request-headers.snippet | 13 + 2 files changed, 229 insertions(+), 168 deletions(-) create mode 100644 src/test/resources/org/springframework/restdocs/templates/asciidoctor/request-headers.snippet diff --git a/src/docs/asciidoc/index.html b/src/docs/asciidoc/index.html index 2291df4e..88a73c93 100644 --- a/src/docs/asciidoc/index.html +++ b/src/docs/asciidoc/index.html @@ -573,9 +573,9 @@

    Request

    {
    -  "email" : "davina.hickle@yahoo.com",
    -  "password" : "3Q#Kd29725$bTcJ^T#$*2",
    -  "nickname" : "daisy.oconnell"
    +  "email" : "gavin.lakin@hotmail.com",
    +  "password" : "BNc@^R!#tM&Prm0WcOIf5Jm1w",
    +  "nickname" : "esteban.haag"
     }
    @@ -616,13 +616,13 @@

    Request examp
    POST /api/v1/auth/signup HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 114
    +Content-Length: 116
     Host: docs.api.com
     
     {
    -  "email" : "davina.hickle@yahoo.com",
    -  "password" : "3Q#Kd29725$bTcJ^T#$*2",
    -  "nickname" : "daisy.oconnell"
    +  "email" : "gavin.lakin@hotmail.com",
    +  "password" : "BNc@^R!#tM&Prm0WcOIf5Jm1w",
    +  "nickname" : "esteban.haag"
     }

    @@ -664,8 +664,8 @@

    Request

    {
    -  "email" : "darrell.murphy@hotmail.com",
    -  "password" : "Fv0V0D15%"
    +  "email" : "williams.flatley@yahoo.com",
    +  "password" : "Xz#0^3%v8$yk0o%o"
     }
    @@ -701,12 +701,12 @@

    Request e
    POST /api/v1/auth/login HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Content-Length: 72
    +Content-Length: 79
     Host: docs.api.com
     
     {
    -  "email" : "darrell.murphy@hotmail.com",
    -  "password" : "Fv0V0D15%"
    +  "email" : "williams.flatley@yahoo.com",
    +  "password" : "Xz#0^3%v8$yk0o%o"
     }
    @@ -717,7 +717,7 @@

    Response

    {
    -  "token" : "ffa6ef4739d461448c4e21a16cfb0a9ddfc34f51f051b316af7f082f1cde024987d8d345c1317af230451d9d8e3d825ce677d73e74183e3ad5188afa76f1117f"
    +  "token" : "a5fbfa1c2fd6a064babe4b7234f141fe57733ee9c53839bb31a0284a7b0a3a49b2894252b81e86078ecc0d9a7e24dc81372376b006d457ede46a8d9d1ea0ff93"
     }
    @@ -750,12 +750,12 @@

    Respons Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers -Authorization: Bearer ffa6ef4739d461448c4e21a16cfb0a9ddfc34f51f051b316af7f082f1cde024987d8d345c1317af230451d9d8e3d825ce677d73e74183e3ad5188afa76f1117f +Authorization: Bearer a5fbfa1c2fd6a064babe4b7234f141fe57733ee9c53839bb31a0284a7b0a3a49b2894252b81e86078ecc0d9a7e24dc81372376b006d457ede46a8d9d1ea0ff93 Content-Type: application/json Content-Length: 146 { - "token" : "ffa6ef4739d461448c4e21a16cfb0a9ddfc34f51f051b316af7f082f1cde024987d8d345c1317af230451d9d8e3d825ce677d73e74183e3ad5188afa76f1117f" + "token" : "a5fbfa1c2fd6a064babe4b7234f141fe57733ee9c53839bb31a0284a7b0a3a49b2894252b81e86078ecc0d9a7e24dc81372376b006d457ede46a8d9d1ea0ff93" } @@ -802,7 +802,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certificate?email=boyd.wunsch@yahoo.com HTTP/1.1
    +
    PATCH /api/v1/auth/certificate?email=magnolia.becker@yahoo.com HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -868,7 +868,7 @@

    Request

    Request example

    -
    PATCH /api/v1/auth/certify?email=leo.oreilly@example.com&code=9EB7pW HTTP/1.1
    +
    PATCH /api/v1/auth/certify?email=emery.kutch@example.com&code=Q8K940 HTTP/1.1
     Content-Type: application/json;charset=UTF-8
     Host: docs.api.com
    @@ -914,21 +914,26 @@

    upload

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    true

    @@ -980,13 +985,14 @@

    Request

    +

    Request example

    POST /api/v1/avatar-items HTTP/1.1
     Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjA4LCJleHAiOjE3MDU1NTc4MDgsInVzZXJfaWQiOjQ2NzgwNDA0NH0.8F4AmIZAU0qz5b8JEYmMbN-pf6t_0k5F4hO4qOiMfcD1z_fionWWK7OLtlr1JwqRlgDbDmoZOb9f9s_7xNS3kA
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTgyLCJleHAiOjE3MDU1NzQ1ODIsInVzZXJfaWQiOjUyODI5OTAzMH0.yILk1vXe2vX81teF_UVtLqCh-tqyCgnOYlQLUU0alnzVpxGY-3gd6oUbmHmFeMowDsoCJzGEH0G2nwHW6hCEwQ
     Accept: application/json
     Host: docs.api.com
     
    @@ -1010,10 +1016,10 @@ 

    Response

    {
    -  "avatarItemId" : 467804044,
    +  "avatarItemId" : 528299030,
       "type" : "HAIR",
       "sex" : "MALE",
    -  "url" : "https://www.jerold-hermiston.info:22946/debitis/beatae#dicta"
    +  "url" : "https://www.alva-reinger.org:4583/nam/harumofficiis?consectetur=esse&sequi=dolorem"
     }
    @@ -1062,13 +1068,13 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 143 +Content-Length: 165 { - "avatarItemId" : 467804044, + "avatarItemId" : 528299030, "type" : "HAIR", "sex" : "MALE", - "url" : "https://www.jerold-hermiston.info:22946/debitis/beatae#dicta" + "url" : "https://www.alva-reinger.org:4583/nam/harumofficiis?consectetur=esse&sequi=dolorem" }

    @@ -1112,12 +1118,12 @@

    Response

    "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "https://www.nelle-bogisich.co:61111/neque/hicperferendis?nihil=vel&quis=maxime#iste" + "url" : "http://www.williams-crooks.biz/" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.caroyln-howell.org:10354/praesentium" + "url" : "https://www.elyse-volkman.io/earum/eius?voluptas=rerum&voluptas=exercitationem#vel" } ]
    @@ -1166,18 +1172,18 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 288 +Content-Length: 270 [ { "avatarItemId" : 1, "type" : "HAIR", "sex" : "MALE", - "url" : "https://www.nelle-bogisich.co:61111/neque/hicperferendis?nihil=vel&quis=maxime#iste" + "url" : "http://www.williams-crooks.biz/" }, { "avatarItemId" : 2, "type" : "TOP", "sex" : "FEMALE", - "url" : "https://www.caroyln-howell.org:10354/praesentium" + "url" : "https://www.elyse-volkman.io/earum/eius?voluptas=rerum&voluptas=exercitationem#vel" } ]

    @@ -1208,21 +1214,26 @@

    post create

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    true

    @@ -1284,13 +1295,14 @@

    Request

    +

    Request example

    POST /api/v1/posts HTTP/1.1
     Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTg0LCJleHAiOjE3MDU1NzQ1ODQsInVzZXJfaWQiOjF9.mTcgBjKPrrKkjVtfmEk0MJyDI-8PQyKuXrzwr2w1_I8mwQq5lT6PkW9eMPNfCee2vdtxCj6HF_U2rN_yqcbgRA
     Accept: application/json
     Host: docs.api.com
     
    @@ -1298,7 +1310,7 @@ 

    Request e Content-Disposition: form-data; name=request; filename=request.json Content-Type: application/json -{"title":"His Dark Materials","content":"Carbon","coordinate":{"nx":50,"ny":127}} +{"title":"Arms and the Man","content":"Tin","coordinate":{"nx":50,"ny":127}} --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm Content-Disposition: form-data; name=postImg; filename=image.jpeg Content-Type: image/jpeg @@ -1315,11 +1327,11 @@

    Response

    {
       "postId" : 1,
    -  "title" : "His Dark Materials",
    -  "content" : "Carbon",
    -  "image" : "https://www.macy-buckridge.co:60790/dolorem",
    -  "createdAt" : "2024-01-18T14:03:31.195215",
    -  "updatedAt" : "2024-01-18T14:03:31.195222",
    +  "title" : "Arms and the Man",
    +  "content" : "Tin",
    +  "image" : "https://www.arnulfo-runolfsdottir.info/?architecto=ut&impedit=aperiam",
    +  "createdAt" : "2024-01-18T18:43:04.877194",
    +  "updatedAt" : "2024-01-18T18:43:04.877208",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
    @@ -1393,15 +1405,15 @@ 

    Respons Vary: Access-Control-Request-Headers Location: /api/v1/posts/1 Content-Type: application/json -Content-Length: 293 +Content-Length: 314 { "postId" : 1, - "title" : "His Dark Materials", - "content" : "Carbon", - "image" : "https://www.macy-buckridge.co:60790/dolorem", - "createdAt" : "2024-01-18T14:03:31.195215", - "updatedAt" : "2024-01-18T14:03:31.195222", + "title" : "Arms and the Man", + "content" : "Tin", + "image" : "https://www.arnulfo-runolfsdottir.info/?architecto=ut&impedit=aperiam", + "createdAt" : "2024-01-18T18:43:04.877194", + "updatedAt" : "2024-01-18T18:43:04.877208", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 @@ -1430,21 +1442,26 @@

    post read d

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    false

    @@ -1467,13 +1484,14 @@

    Request

    +

    Request example

    -
    GET /api/v1/posts/1438852838 HTTP/1.1
    +
    GET /api/v1/posts/1803095596 HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTg0LCJleHAiOjE3MDU1NzQ1ODQsInVzZXJfaWQiOjF9.mTcgBjKPrrKkjVtfmEk0MJyDI-8PQyKuXrzwr2w1_I8mwQq5lT6PkW9eMPNfCee2vdtxCj6HF_U2rN_yqcbgRA
     Accept: application/json
     Host: docs.api.com
    @@ -1485,22 +1503,22 @@

    Response

    {
    -  "postId" : 1438852838,
    +  "postId" : 1803095596,
       "writer" : {
    -    "userId" : 930304021,
    -    "nickname" : "vida.daniel",
    -    "image" : "http://www.rosendo-dietrich.biz/ut/et#harum"
    +    "userId" : 412308604,
    +    "nickname" : "jay.grimes",
    +    "image" : "http://www.wyatt-terry.biz/?et=incidunt&possimus=saepe#maxime"
       },
    -  "title" : "For Whom the Bell Tolls",
    -  "content" : "Germanium",
    -  "image" : "https://www.tisa-schimmel.name/corporis/magnam?quaerat=qui&eius=rerum",
    -  "createdAt" : "2024-01-18T14:03:31.152578",
    -  "updatedAt" : "2024-01-18T14:03:31.152586",
    +  "title" : "The Lathe of Heaven",
    +  "content" : "Californium",
    +  "image" : "https://www.breanne-waelchi.org:43673/ullam/sequiodio#earum",
    +  "createdAt" : "2024-01-18T18:43:04.832065",
    +  "updatedAt" : "2024-01-18T18:43:04.832079",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 32,
    +  "likeCnt" : 33,
       "isLike" : 0
     }
    @@ -1595,25 +1613,25 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 508 +Content-Length: 513 { - "postId" : 1438852838, + "postId" : 1803095596, "writer" : { - "userId" : 930304021, - "nickname" : "vida.daniel", - "image" : "http://www.rosendo-dietrich.biz/ut/et#harum" + "userId" : 412308604, + "nickname" : "jay.grimes", + "image" : "http://www.wyatt-terry.biz/?et=incidunt&possimus=saepe#maxime" }, - "title" : "For Whom the Bell Tolls", - "content" : "Germanium", - "image" : "https://www.tisa-schimmel.name/corporis/magnam?quaerat=qui&eius=rerum", - "createdAt" : "2024-01-18T14:03:31.152578", - "updatedAt" : "2024-01-18T14:03:31.152586", + "title" : "The Lathe of Heaven", + "content" : "Californium", + "image" : "https://www.breanne-waelchi.org:43673/ullam/sequiodio#earum", + "createdAt" : "2024-01-18T18:43:04.832065", + "updatedAt" : "2024-01-18T18:43:04.832079", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 32, + "likeCnt" : 33, "isLike" : 0 }

    @@ -1639,31 +1657,37 @@

    post read all

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    false

    +

    Request example

    GET /api/v1/posts HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTg0LCJleHAiOjE3MDU1NzQ1ODQsInVzZXJfaWQiOjF9.mTcgBjKPrrKkjVtfmEk0MJyDI-8PQyKuXrzwr2w1_I8mwQq5lT6PkW9eMPNfCee2vdtxCj6HF_U2rN_yqcbgRA
     Accept: application/json
     Host: docs.api.com
    @@ -1675,58 +1699,58 @@

    Response

    [ {
    -  "postId" : 1377184747,
    +  "postId" : 1908042653,
       "writer" : {
    -    "userId" : 2132280395,
    -    "nickname" : "saul.leffler",
    -    "image" : "https://www.jules-douglas.org:55369/rerum#autem"
    +    "userId" : 934467639,
    +    "nickname" : "alfredo.schmidt",
    +    "image" : "http://www.king-huels.com:45991/nemo/et?quas=vero&debitis=consequatur#ut"
       },
    -  "title" : "By Grand Central Station I Sat Down and Wept",
    -  "content" : "Molybdenum",
    -  "image" : "http://www.tamatha-cremin.org:55843/voluptate/velitquibusdam?amet=dicta&in=et",
    -  "createdAt" : "2024-01-18T14:03:31.0926",
    -  "updatedAt" : "2024-01-18T14:03:31.092606",
    +  "title" : "An Acceptable Time",
    +  "content" : "Cobalt",
    +  "image" : "https://www.lowell-rogahn.io:60654/#molestias",
    +  "createdAt" : "2024-01-18T18:43:04.779531",
    +  "updatedAt" : "2024-01-18T18:43:04.779548",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 3,
    +  "likeCnt" : 54,
       "isLike" : 0
     }, {
    -  "postId" : 970591755,
    +  "postId" : 976739760,
       "writer" : {
    -    "userId" : 784295722,
    -    "nickname" : "alton.doyle",
    -    "image" : "https://www.consuelo-pagac.io:34024/qui/dignissimosaccusantium#minus"
    +    "userId" : 1468392497,
    +    "nickname" : "georgianne.yundt",
    +    "image" : "http://www.sherilyn-pollich.org/dolores?cumque=magnam&dolor=nulla#deleniti"
       },
    -  "title" : "Ring of Bright Water",
    -  "content" : "Protactinium",
    -  "image" : "https://www.georgiann-jenkins.org/aut/porro?cupiditate=eius&ea=eum#nulla",
    -  "createdAt" : "2024-01-18T14:03:31.094355",
    -  "updatedAt" : "2024-01-18T14:03:31.09436",
    +  "title" : "The Little Foxes",
    +  "content" : "Helium",
    +  "image" : "https://www.georgette-hirthe.net/aperiam/optio?eum=molestiae&aut=officiis#illum",
    +  "createdAt" : "2024-01-18T18:43:04.782134",
    +  "updatedAt" : "2024-01-18T18:43:04.78215",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 38,
    +  "likeCnt" : 55,
       "isLike" : 0
     }, {
    -  "postId" : 126153066,
    +  "postId" : 1153411505,
       "writer" : {
    -    "userId" : 631346244,
    -    "nickname" : "claris.batz",
    -    "image" : "https://www.vaughn-blick.com/nihil/quod#incidunt"
    +    "userId" : 682342469,
    +    "nickname" : "marlin.nienow",
    +    "image" : "https://www.darrick-kozey.io:61868/perspiciatis#quae"
       },
    -  "title" : "Nine Coaches Waiting",
    -  "content" : "Tin",
    -  "image" : "https://www.bill-zboncak.info/ut/excepturi?unde=mollitia&dolor=distinctio",
    -  "createdAt" : "2024-01-18T14:03:31.094551",
    -  "updatedAt" : "2024-01-18T14:03:31.094553",
    +  "title" : "Precious Bane",
    +  "content" : "Potassium",
    +  "image" : "http://www.corrine-west.biz/a/dolorem?sit=dolorem&molestias=aliquid",
    +  "createdAt" : "2024-01-18T18:43:04.78255",
    +  "updatedAt" : "2024-01-18T18:43:04.782565",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
       },
    -  "likeCnt" : 19,
    +  "likeCnt" : 70,
       "isLike" : 0
     } ]
    @@ -1821,61 +1845,61 @@

    Respons Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json -Content-Length: 1590 +Content-Length: 1566 [ { - "postId" : 1377184747, + "postId" : 1908042653, "writer" : { - "userId" : 2132280395, - "nickname" : "saul.leffler", - "image" : "https://www.jules-douglas.org:55369/rerum#autem" + "userId" : 934467639, + "nickname" : "alfredo.schmidt", + "image" : "http://www.king-huels.com:45991/nemo/et?quas=vero&debitis=consequatur#ut" }, - "title" : "By Grand Central Station I Sat Down and Wept", - "content" : "Molybdenum", - "image" : "http://www.tamatha-cremin.org:55843/voluptate/velitquibusdam?amet=dicta&in=et", - "createdAt" : "2024-01-18T14:03:31.0926", - "updatedAt" : "2024-01-18T14:03:31.092606", + "title" : "An Acceptable Time", + "content" : "Cobalt", + "image" : "https://www.lowell-rogahn.io:60654/#molestias", + "createdAt" : "2024-01-18T18:43:04.779531", + "updatedAt" : "2024-01-18T18:43:04.779548", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 3, + "likeCnt" : 54, "isLike" : 0 }, { - "postId" : 970591755, + "postId" : 976739760, "writer" : { - "userId" : 784295722, - "nickname" : "alton.doyle", - "image" : "https://www.consuelo-pagac.io:34024/qui/dignissimosaccusantium#minus" + "userId" : 1468392497, + "nickname" : "georgianne.yundt", + "image" : "http://www.sherilyn-pollich.org/dolores?cumque=magnam&dolor=nulla#deleniti" }, - "title" : "Ring of Bright Water", - "content" : "Protactinium", - "image" : "https://www.georgiann-jenkins.org/aut/porro?cupiditate=eius&ea=eum#nulla", - "createdAt" : "2024-01-18T14:03:31.094355", - "updatedAt" : "2024-01-18T14:03:31.09436", + "title" : "The Little Foxes", + "content" : "Helium", + "image" : "https://www.georgette-hirthe.net/aperiam/optio?eum=molestiae&aut=officiis#illum", + "createdAt" : "2024-01-18T18:43:04.782134", + "updatedAt" : "2024-01-18T18:43:04.78215", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 38, + "likeCnt" : 55, "isLike" : 0 }, { - "postId" : 126153066, + "postId" : 1153411505, "writer" : { - "userId" : 631346244, - "nickname" : "claris.batz", - "image" : "https://www.vaughn-blick.com/nihil/quod#incidunt" + "userId" : 682342469, + "nickname" : "marlin.nienow", + "image" : "https://www.darrick-kozey.io:61868/perspiciatis#quae" }, - "title" : "Nine Coaches Waiting", - "content" : "Tin", - "image" : "https://www.bill-zboncak.info/ut/excepturi?unde=mollitia&dolor=distinctio", - "createdAt" : "2024-01-18T14:03:31.094551", - "updatedAt" : "2024-01-18T14:03:31.094553", + "title" : "Precious Bane", + "content" : "Potassium", + "image" : "http://www.corrine-west.biz/a/dolorem?sit=dolorem&molestias=aliquid", + "createdAt" : "2024-01-18T18:43:04.78255", + "updatedAt" : "2024-01-18T18:43:04.782565", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 }, - "likeCnt" : 19, + "likeCnt" : 70, "isLike" : 0 } ]

    @@ -1901,21 +1925,26 @@

    post update

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    true

    @@ -1967,13 +1996,14 @@

    Request

    +

    Request example

    PUT /api/v1/posts/2 HTTP/1.1
     Content-Type: multipart/form-data;charset=UTF-8; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTg0LCJleHAiOjE3MDU1NzQ1ODQsInVzZXJfaWQiOjF9.mTcgBjKPrrKkjVtfmEk0MJyDI-8PQyKuXrzwr2w1_I8mwQq5lT6PkW9eMPNfCee2vdtxCj6HF_U2rN_yqcbgRA
     Accept: application/json
     Host: docs.api.com
     
    @@ -1981,7 +2011,7 @@ 

    Request Content-Disposition: form-data; name=request; filename=request.json Content-Type: application/json -{"title":"The Wives of Bath","content":"Erbium"} +{"title":"Absalom, Absalom!","content":"Neodymium"} --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm Content-Disposition: form-data; name=postImg; filename=image.jpeg Content-Type: image/jpeg @@ -1998,11 +2028,11 @@

    Response

    {
       "postId" : 2,
    -  "title" : "The Wives of Bath",
    -  "content" : "Erbium",
    -  "image" : "https://www.claud-huels.biz/",
    -  "createdAt" : "2024-01-18T14:03:31.255841",
    -  "updatedAt" : "2024-01-18T14:03:31.255869",
    +  "title" : "Absalom, Absalom!",
    +  "content" : "Neodymium",
    +  "image" : "https://www.shelby-schaefer.name:21573/et/distinctiofugiat?magnam=consequatur&consectetur=doloremque#corrupti",
    +  "createdAt" : "2024-01-18T18:43:04.934907",
    +  "updatedAt" : "2024-01-18T18:43:04.934923",
       "temperatureArrange" : {
         "min" : 0.0,
         "max" : 15.0
    @@ -2076,15 +2106,15 @@ 

    Respo Vary: Access-Control-Request-Headers Location: /api/v1/posts/2 Content-Type: application/json -Content-Length: 277 +Content-Length: 361 { "postId" : 2, - "title" : "The Wives of Bath", - "content" : "Erbium", - "image" : "https://www.claud-huels.biz/", - "createdAt" : "2024-01-18T14:03:31.255841", - "updatedAt" : "2024-01-18T14:03:31.255869", + "title" : "Absalom, Absalom!", + "content" : "Neodymium", + "image" : "https://www.shelby-schaefer.name:21573/et/distinctiofugiat?magnam=consequatur&consectetur=doloremque#corrupti", + "createdAt" : "2024-01-18T18:43:04.934907", + "updatedAt" : "2024-01-18T18:43:04.934923", "temperatureArrange" : { "min" : 0.0, "max" : 15.0 @@ -2113,21 +2143,26 @@

    post delete

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    true

    @@ -2150,12 +2185,13 @@

    Request

    +

    Request example

    -
    DELETE /api/v1/posts/1570303977 HTTP/1.1
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjExLCJleHAiOjE3MDU1NTc4MTEsInVzZXJfaWQiOjF9.P7fXhU5mxjcvHAuL3ka5nBEBR-cX5XOSqtjJ8-QqS8_G_AGt9p9SIZJivLWP64-3GDCZmk8AbAJFqGWk0pe41w
    +
    DELETE /api/v1/posts/1744803171 HTTP/1.1
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTg0LCJleHAiOjE3MDU1NzQ1ODQsInVzZXJfaWQiOjF9.mTcgBjKPrrKkjVtfmEk0MJyDI-8PQyKuXrzwr2w1_I8mwQq5lT6PkW9eMPNfCee2vdtxCj6HF_U2rN_yqcbgRA
     Host: docs.api.com
    @@ -2194,28 +2230,33 @@

    like push

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    true

    {
    -  "postId" : 1698117767
    +  "postId" : 1251693879
     }
    @@ -2240,19 +2281,20 @@

    Request

    +

    Request example

    -
    POST /api/v1/posts/1698117767/likes HTTP/1.1
    +
    POST /api/v1/posts/1251693879/likes HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjA5LCJleHAiOjE3MDU1NTc4MDksInVzZXJfaWQiOjEzODAzNjQ2ODd9.avTFFTmbr4VEjYkHmehAvEXvNP4GGrX-mKzBWq5Nxidiphvpmx0QBvPyU2PmheLGYGZKEiqLFwAwPGqT1SLakA
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTgzLCJleHAiOjE3MDU1NzQ1ODMsInVzZXJfaWQiOjIxNDIzNzM3MjN9.soHfQaFbqHJl5xPC3moiDjk4fXWy9l0oTTliB9oSzqsfArjZKeBV5KuWtc_1cm4e1AO-PhBr2V4_m9h2Et_3vg
     Accept: application/json
     Content-Length: 27
     Host: docs.api.com
     
     {
    -  "postId" : 1698117767
    +  "postId" : 1251693879
     }
    @@ -2263,9 +2305,9 @@

    Response

    {
    -  "likeId" : 904660687,
    -  "userId" : 1380364687,
    -  "postId" : 1698117767,
    +  "likeId" : 581393781,
    +  "userId" : 2142373723,
    +  "postId" : 1251693879,
       "status" : true
     }
    @@ -2318,9 +2360,9 @@

    Respo Content-Length: 95 { - "likeId" : 904660687, - "userId" : 1380364687, - "postId" : 1698117767, + "likeId" : 581393781, + "userId" : 2142373723, + "postId" : 1251693879, "status" : true }

    @@ -2352,21 +2394,26 @@

    current weath

    Request

    +
    +

    Request Headers

    --+++ + +
    Name DescriptionRequired

    Authorization

    JWT 토큰

    true

    @@ -2392,13 +2439,14 @@

    Request

    +

    Request example

    GET /api/v1/weather?nx=50&ny=127 HTTP/1.1
     Content-Type: application/json;charset=UTF-8
    -Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTU0MjE0LCJleHAiOjE3MDU1NTc4MTQsInVzZXJfaWQiOjF9.aIpCeqrSrBPcYGc29tSrDQ2Jka7FQuu0RcfVE9XZQu3swBzZjBXajl0-NWWsTZhdE-QhiRTa-eRPt4nx8bsnPw
    +Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvb3R3IiwiaWF0IjoxNzA1NTcwOTg3LCJleHAiOjE3MDU1NzQ1ODcsInVzZXJfaWQiOjF9.PXvjVy9boT_qqEC9Vt0SWy2OjUPPj3wbUtTJ5iUyh21-u3C9WfWh_gH2AvAqo3Cj6XWP0twgbUmBUlM_XYChFw
     Accept: application/json
     Host: docs.api.com
    diff --git a/src/test/resources/org/springframework/restdocs/templates/asciidoctor/request-headers.snippet b/src/test/resources/org/springframework/restdocs/templates/asciidoctor/request-headers.snippet new file mode 100644 index 00000000..439fd66f --- /dev/null +++ b/src/test/resources/org/springframework/restdocs/templates/asciidoctor/request-headers.snippet @@ -0,0 +1,13 @@ +==== Request Headers + +|=== +|Name|Description|Required + +{{#headers}} + +|{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} +|{{#tableCellContent}}{{description}}{{/tableCellContent}} +|{{#tableCellContent}}{{#optional}}false{{/optional}}{{^optional}}true{{/optional}}{{/tableCellContent}} + +{{/headers}} +|===