diff --git a/backend/emm-sale/src/docs/asciidoc/index.adoc b/backend/emm-sale/src/docs/asciidoc/index.adoc index d3f71ca08..85bb2e326 100644 --- a/backend/emm-sale/src/docs/asciidoc/index.adoc +++ b/backend/emm-sale/src/docs/asciidoc/index.adoc @@ -194,3 +194,16 @@ include::{snippets}/modify-comment/http-response.adoc[] .HTTP response 설명 include::{snippets}/modify-comment/response-fields.adoc[] + +== Login + +=== `POST` : 로그인 및 가입 + +.HTTP request +include::{snippets}/login-snippet/http-request.adoc[] + +.HTTP response +include::{snippets}/login-snippet/http-response.adoc[] + +.HTTP response +include::{snippets}/login-snippet/response-fields.adoc[] diff --git a/backend/emm-sale/src/main/resources/static/docs/index.html b/backend/emm-sale/src/main/resources/static/docs/index.html index 84d1746b5..59803df07 100644 --- a/backend/emm-sale/src/main/resources/static/docs/index.html +++ b/backend/emm-sale/src/main/resources/static/docs/index.html @@ -469,6 +469,26 @@

EMM-SALE API Docs

  • PUT: 사용자의 Open Profile URL 업데이트
  • +
  • Event + +
  • +
  • Comment + +
  • +
  • Login + +
  • @@ -1568,7 +1588,7 @@

    HTTP request
    -
    PUT /members/openprofile HTTP/1.1
    +
    PUT /members/open-profile-url HTTP/1.1
     Content-Type: application/json
     Content-Length: 66
     Host: localhost:8080
    @@ -1581,9 +1601,816 @@ 

    HTTP response
    -
    HTTP/1.1 200 OK
    +
    HTTP/1.1 204 No Content
    +
    +

    + + + +
    +

    Event

    +
    +
    +

    GET : 행사 상세정보 조회

    +
    +
    HTTP request
    +
    +
    GET /events/1 HTTP/1.1
    +Host: localhost:8080
    +
    +
    +
    +
    HTTP response
    +
    +
    HTTP/1.1 200 OK
    +Content-Type: application/json
    +Content-Length: 272
    +
    +{
    +  "id" : 1,
    +  "name" : "인프콘 2023",
    +  "informationUrl" : "http://infcon.com",
    +  "startDate" : "2023:08:15:12:00:00",
    +  "endDate" : "2023:08:15:12:00:00",
    +  "location" : "코엑스",
    +  "status" : "예정",
    +  "tags" : [ "코틀린", "백엔드", "안드로이드" ]
    +}
    +
    +
    + + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Table 23. HTTP response 설명
    PathTypeDescription

    id

    Number

    event 식별자

    name

    String

    envent 이름

    informationUrl

    String

    상세정보 url

    startDate

    String

    시작일자

    endDate

    String

    종료일자

    location

    String

    장소

    status

    String

    진행상태

    tags[]

    Array

    태그들

    +
    +
    +

    POST : 컨퍼런스에 함께가기 요청(컨퍼런스에 함께 가는 멤버에 등록)

    +
    +
    HTTP request
    +
    +
    POST /events/1/participants HTTP/1.1
    +Content-Type: application/json
    +Authorization: Bearer accessToken
    +Content-Length: 20
    +Host: localhost:8080
    +
    +{
    +  "memberId" : 2
    +}
    +
    +
    +
    +
    HTTP response
    +
    +
    HTTP/1.1 201 Created
    +Location: /events/1/participants/3
    +
    +
    +
    +
    +

    GET: 행사 목록 조회

    +
    +
    HTTP request
    +
    +
    GET /events?year=2023&month=7 HTTP/1.1
    +Host: localhost:8080
    +
    +
    + + ++++ + + + + + + + + + + + + + + + + + + + + + + + + +
    Table 24. HTTP request 설명
    ParameterDescription

    year

    조회하고자 하는 연도(2015 이상의 값)

    month

    조회하고자 하는 월(1~12)

    tag

    필터링하려는 태그(option)

    status

    필터링하려는 상태(option)

    +
    +
    HTTP response
    +
    +
    HTTP/1.1 200 OK
    +Content-Type: application/json
    +Content-Length: 814
    +
    +[ {
    +  "id" : 1,
    +  "name" : "인프콘 2023",
    +  "startDate" : "2023:06:03:12:00:00",
    +  "endDate" : "2023:09:03:12:00:00",
    +  "tags" : [ "백엔드", "프론트엔드", "안드로이드", "IOS", "AI" ],
    +  "status" : "진행 중"
    +}, {
    +  "id" : 5,
    +  "name" : "웹 컨퍼런스",
    +  "startDate" : "2023:07:03:12:00:00",
    +  "endDate" : "2023:08:03:12:00:00",
    +  "tags" : [ "백엔드", "프론트엔드" ],
    +  "status" : "진행 중"
    +}, {
    +  "id" : 2,
    +  "name" : "AI 컨퍼런스",
    +  "startDate" : "2023:07:22:12:00:00",
    +  "endDate" : "2023:07:30:12:00:00",
    +  "tags" : [ "AI" ],
    +  "status" : "진행 예정"
    +}, {
    +  "id" : 4,
    +  "name" : "안드로이드 컨퍼런스",
    +  "startDate" : "2023:06:29:12:00:00",
    +  "endDate" : "2023:07:16:12:00:00",
    +  "tags" : [ "백엔드", "프론트엔드" ],
    +  "status" : "종료된 행사"
    +} ]
    +
    +
    + + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Table 25. HTTP response 설명
    PathTypeDescription

    [].id

    Number

    행사 id

    [].name

    String

    행사명

    [].startDate

    String

    행사 시작일(yyyy:MM:dd:HH:mm:ss)

    [].endDate

    String

    행사 종료일(yyyy:MM:dd:HH:mm:ss)

    [].tags[]

    Array

    행사 태그 목록

    [].status

    String

    행사 진행 상황

    +
    +
    +
    +
    +

    Comment

    +
    +
    +

    GET : 댓글 모두 조회

    + + ++++ + + + + + + + + + + + + +
    Table 26. HTTP request 설명
    ParameterDescription

    eventId

    댓글을 볼 행사 id

    +
    +
    HTTP request
    +
    +
    GET /comments?eventId=1 HTTP/1.1
    +Host: localhost:8080
    +
    +
    +
    +
    HTTP response
    +
    +
    HTTP/1.1 200 OK
    +Content-Type: application/json
    +Content-Length: 1313
    +
    +[ {
    +  "parentComment" : {
    +    "content" : "부모댓글2",
    +    "commentId" : 4,
    +    "parentId" : null,
    +    "eventId" : 1,
    +    "createdAt" : "2023:07:28:15:35:17",
    +    "updatedAt" : "2023:07:28:15:35:17",
    +    "memberId" : 1,
    +    "memberImageUrl" : "이미지",
    +    "memberName" : "이름1",
    +    "deleted" : false
    +  },
    +  "childComments" : [ ]
    +}, {
    +  "parentComment" : {
    +    "content" : "부모댓글1",
    +    "commentId" : 5,
    +    "parentId" : null,
    +    "eventId" : 1,
    +    "createdAt" : "2023:07:28:15:35:17",
    +    "updatedAt" : "2023:07:28:15:35:17",
    +    "memberId" : 1,
    +    "memberImageUrl" : "이미지",
    +    "memberName" : "이름1",
    +    "deleted" : false
    +  },
    +  "childComments" : [ {
    +    "content" : "부모댓글1에 대한 자식댓글1",
    +    "commentId" : 2,
    +    "parentId" : 1,
    +    "eventId" : 1,
    +    "createdAt" : "2023:07:28:15:35:17",
    +    "updatedAt" : "2023:07:28:15:35:17",
    +    "memberId" : 1,
    +    "memberImageUrl" : "이미지",
    +    "memberName" : "이름1",
    +    "deleted" : false
    +  }, {
    +    "content" : "부모댓글1에 대한 자식댓글2",
    +    "commentId" : 3,
    +    "parentId" : 1,
    +    "eventId" : 1,
    +    "createdAt" : "2023:07:28:15:35:17",
    +    "updatedAt" : "2023:07:28:15:35:17",
    +    "memberId" : 1,
    +    "memberImageUrl" : "이미지",
    +    "memberName" : "이름1",
    +    "deleted" : false
    +  } ]
    +} ]
    + + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Table 27. HTTP response 설명
    PathTypeDescription

    [].parentComment.content

    String

    댓글 내용

    [].parentComment.commentId

    Number

    댓글 ID

    [].parentComment.parentId

    Null

    부모 댓글 ID

    [].parentComment.eventId

    Number

    이벤트 ID

    [].parentComment.deleted

    Boolean

    댓글 삭제 여부

    [].parentComment.createdAt

    String

    댓글 생성 날짜

    [].parentComment.updatedAt

    String

    댓글 수정 날짜

    [].parentComment.memberId

    Number

    댓글 작성자 ID

    [].parentComment.memberImageUrl

    String

    댓글 작성자 이미지 Url

    [].parentComment.memberName

    String

    댓글 작성자 이름

    [].childComments[]

    Array

    자식 댓글 목록

    [].childComments[].content

    String

    댓글 내용

    [].childComments[].commentId

    Number

    댓글 ID

    [].childComments[].parentId

    Number

    부모 댓글 ID

    [].childComments[].eventId

    Number

    이벤트 ID

    [].childComments[].deleted

    Boolean

    댓글 삭제 여부

    [].childComments[].createdAt

    String

    댓글 생성 날짜

    [].childComments[].updatedAt

    String

    댓글 수정 날짜

    [].childComments[].memberId

    Number

    댓글 작성자 ID

    [].childComments[].memberImageUrl

    String

    댓글 작성자 이미지 Url

    [].childComments[].memberName

    String

    댓글 작성자 이름

    +
    +
    +

    POST : 댓글 및 대댓글 생성

    +
    +
    HTTP request
    +
    +
    POST /comments HTTP/1.1
    +Content-Type: application/json
    +Content-Length: 64
    +Host: localhost:8080
    +
    +{
    +  "content" : "내용",
    +  "eventId" : 1,
    +  "parentId" : null
    +}
    +
    +
    +
    +
    HTTP response
    +
    +
    HTTP/1.1 200 OK
    +Content-Type: application/json
    +Content-Length: 259
    +
    +{
    +  "content" : "내용",
    +  "commentId" : 2,
    +  "parentId" : 1,
    +  "eventId" : 1,
    +  "createdAt" : "2023:07:28:15:35:17",
    +  "updatedAt" : "2023:07:28:15:35:17",
    +  "memberId" : 1,
    +  "memberImageUrl" : "이미지",
    +  "memberName" : "이름1",
    +  "deleted" : false
    +}
    +
    +
    + + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Table 28. HTTP response 설명
    PathTypeDescription

    content

    String

    저장된 댓글 내용

    commentId

    Number

    저장된 댓글 id

    parentId

    Number

    대댓글일 경우 부모 댓글 id

    eventId

    Number

    행사 id

    createdAt

    String

    댓글 생성 시간

    updatedAt

    String

    댓글 최근 수정 시간

    deleted

    Boolean

    댓글 삭제 여부

    memberId

    Number

    댓글 작성자 ID

    memberImageUrl

    String

    댓글 작성자 이미지 Url

    memberName

    String

    댓글 작성자 이름

    +
    +
    +

    DELETE : 댓글 삭제

    +
    +
    HTTP request
    +
    +
    DELETE /comments/1 HTTP/1.1
    +Host: localhost:8080
    +
    +
    + + ++++ + + + + + + + + + + + + +
    Table 29. /comments/{comment-id}
    ParameterDescription

    comment-id

    삭제할 댓글의 ID

    +
    +
    HTTP response
    +
    +
    HTTP/1.1 204 No Content
    +
    +
    +
    +
    +

    PATCH : 댓글 수정

    +
    +
    HTTP request
    +
    +
    PATCH /comments/1 HTTP/1.1
    +Content-Type: application/json
    +Content-Length: 36
    +Host: localhost:8080
    +
    +{
    +  "content" : "변경된 내용"
    +}
    +
    +
    + + +++++ + + + + + + + + + + + + + + +
    Table 30. HTTP request 설명
    PathTypeDescription

    content

    String

    변경할 댓글 내용

    + + ++++ + + + + + + + + + + + + +
    Table 31. /comments/{comment-id}
    ParameterDescription

    comment-id

    수정할 댓글의 ID

    +
    +
    HTTP response
    +
    +
    HTTP/1.1 200 OK
    +Content-Type: application/json
    +Content-Length: 259
    +
    +{
    +  "content" : "댓",
    +  "commentId" : 5,
    +  "parentId" : null,
    +  "eventId" : 1,
    +  "createdAt" : "2023:07:28:15:35:17",
    +  "updatedAt" : "2023:07:28:15:35:17",
    +  "memberId" : 1,
    +  "memberImageUrl" : "이미지",
    +  "memberName" : "이름1",
    +  "deleted" : false
    +}
    +
    +
    + + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Table 32. HTTP response 설명
    PathTypeDescription

    content

    String

    저장된 댓글 내용

    commentId

    Number

    저장된 댓글 id

    parentId

    Null

    대댓글일 경우 부모 댓글 id

    eventId

    Number

    행사 id

    createdAt

    String

    댓글 생성 시간

    updatedAt

    String

    댓글 최근 수정 시간

    deleted

    Boolean

    댓글 삭제 여부

    memberId

    Number

    댓글 작성자 ID

    memberImageUrl

    String

    댓글 작성자 이미지 Url

    memberName

    String

    댓글 작성자 이름

    +
    +
    +
    +
    +

    Login

    +
    +
    +

    POST : 로그인 및 가입

    +
    +
    HTTP request
    +
    +
    POST /login/github/callback HTTP/1.1
    +Host: localhost:8080
    +Content-Type: application/x-www-form-urlencoded
    +
    +code=code
    +
    +
    +
    +
    HTTP response
    +
    +
    HTTP/1.1 200 OK
    +Content-Type: application/json
    +Content-Length: 77
    +
    +{
    +  "memberId" : 1,
    +  "accessToken" : "access_token",
    +  "newMember" : false
    +}
    +
    +
    + + +++++ + + + + + + + + + + + + + + + + + + + + + + + + +
    Table 33. HTTP response
    PathTypeDescription

    memberId

    Number

    멤버 id

    newMember

    Boolean

    새로운 사용자 여부

    accessToken

    String

    Access Token 값

    @@ -1591,11 +2418,11 @@

    - + \ No newline at end of file diff --git a/backend/emm-sale/src/test/java/com/emmsale/login/api/LoginApiTest.java b/backend/emm-sale/src/test/java/com/emmsale/login/api/LoginApiTest.java index efa5aa7ef..8d3751d0b 100644 --- a/backend/emm-sale/src/test/java/com/emmsale/login/api/LoginApiTest.java +++ b/backend/emm-sale/src/test/java/com/emmsale/login/api/LoginApiTest.java @@ -1,6 +1,11 @@ package com.emmsale.login.api; 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.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -12,6 +17,9 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.restdocs.payload.ResponseFieldsSnippet; +import org.springframework.restdocs.request.RequestParametersSnippet; import org.springframework.test.web.servlet.ResultActions; @WebMvcTest(LoginApi.class) @@ -29,6 +37,16 @@ void availableLoginTest() throws Exception { given(loginService.createToken(code)).willReturn(tokenResponse); + final RequestParametersSnippet requestFields = requestParameters( + parameterWithName("code").description("깃허브 로그인 코드") + ); + + final ResponseFieldsSnippet responseFields = responseFields( + fieldWithPath("memberId").type(JsonFieldType.NUMBER).description("멤버 id"), + fieldWithPath("newMember").type(JsonFieldType.BOOLEAN).description("새로운 사용자 여부"), + fieldWithPath("accessToken").type(JsonFieldType.STRING).description("Access Token 값") + ); + // when final ResultActions result = mockMvc.perform( post("/login/github/callback").param("code", code) @@ -36,7 +54,7 @@ void availableLoginTest() throws Exception { // then result.andExpect(status().isOk()) - .andDo(print()); + .andDo(document("login-snippet", requestFields, responseFields)); } @Test