Skip to content

Commit

Permalink
docs: 회원가입 API 명세 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
cyPark95 committed Jan 28, 2024
1 parent a309c1d commit 53b5923
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ Golden-Ticket API adheres as closely as possible to standard HTTP and REST conve

| 500 Internal Server Error
| An unexpected internal server error occurred
|===
|===

= 사용자 기능

include::user.adoc[]
15 changes: 15 additions & 0 deletions src/docs/asciidoc/user.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
== 회원가입

=== HTTP request fields
include::{snippets}/user/join/success/request-fields.adoc[]

=== HTTP request
include::{snippets}/user/join/success/http-request.adoc[]

=== HTTP response fields

include::{snippets}/user/join/success/response-fields.adoc[]

=== HTTP request

include::{snippets}/user/join/success/http-response.adoc[]
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package site.goldenticket.domain.user.controller;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import site.goldenticket.common.config.ApiTest;
import site.goldenticket.common.config.ApiDocumentation;
import site.goldenticket.domain.user.dto.*;
import site.goldenticket.domain.user.entity.User;
import site.goldenticket.domain.user.repository.UserRepository;
Expand All @@ -16,11 +17,15 @@
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.restdocs.payload.JsonFieldType.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
import static site.goldenticket.common.utils.RestAssuredUtils.*;
import static site.goldenticket.common.utils.UserUtils.*;

@DisplayName("UserController 검증")
class UserControllerTest extends ApiTest {
class UserControllerTest extends ApiDocumentation {

@Autowired
private UserRepository userRepository;
Expand All @@ -36,7 +41,41 @@ void join() {
String url = "/users";

// when
ExtractableResponse<Response> result = restAssuredPost(url, request);
ExtractableResponse<Response> result = RestAssured
.given(spec).log().all()
.contentType(APPLICATION_JSON_VALUE)
.body(request)
.filter(document(
"user/join/success",
getDocumentRequest(),
getDocumentResponse(),
requestFields(
fieldWithPath("name").type(STRING)
.description("이름"),
fieldWithPath("nickname").type(STRING)
.description("닉네임"),
fieldWithPath("email").type(STRING)
.description("이메일"),
fieldWithPath("password").type(STRING)
.description("비밀번호"),
fieldWithPath("phoneNumber").type(STRING)
.description("휴대폰번호"),
fieldWithPath("yanoljaId").type(NUMBER)
.description("야놀자 회원 식별값").optional(),
fieldWithPath("agreement.isMarketing").type(BOOLEAN)
.description("마케팅 동의 여부")
),
responseFields(
fieldWithPath("status").ignored(),
fieldWithPath("message").ignored(),
fieldWithPath("data").type(NUMBER)
.description("사용자 식별값")
)
))
.when()
.post(url)
.then().log().all()
.extract();

// then
assertThat(result.statusCode()).isEqualTo(CREATED.value());
Expand Down

0 comments on commit 53b5923

Please sign in to comment.