api

<!DOCTYPE html>

Stackoverflow Application

Writer : nmcoder - be

v1.0.0. 2023.06.14


1. MemberController

1.1. 회원 가입

http-request
POST /users/signup HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: application/json
Content-Length: 81
Host: localhost:8080

{
  "email" : "jeein@gmail.com",
  "password" : "1234",
  "name" : "jeein Park"
}
Table 1. request-fields
Path Type Description

email

String

이메일

password

String

패스워드

name

String

이름

http-response
HTTP/1.1 201 Created
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: /users/1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Table 2. response-headers
Name Description

Location

Location header. 등록된 리소스의 URI

1.2. 회원 로그인

http-request
POST /users/login HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: application/json
Content-Length: 59
Host: localhost:8080

{
  "username" : "jeein@gmail.com",
  "password" : "1234"
}
Table 3. request-fields
Path Type Description

username

String

아이디(이메일)

password

String

패스워드

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZXJuYW1lIjoiamVlaW5AZ21haWwuY29tIiwic3ViIjoiamVlaW5AZ21haWwuY29tIiwiaWF0IjoxNjg3NDI5ODY4LCJleHAiOjE2ODc0MzE2Njh9.9b1o-T0GUoZCEzMdnvOJAGfg8PnOO81hk1EHBKmDWFM
Refresh: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJqZWVpbkBnbWFpbC5jb20iLCJpYXQiOjE2ODc0Mjk4NjgsImV4cCI6MTY4NzQ1NTA2OH0.DvG8J767XdXsAAqwEsBrkui5u4Tz0iX7jM5L8pOJlgs
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 47

{
  "name" : "jeein Park",
  "memberId" : "1"
}
Table 4. response-headers
Name Description

Authorization

발급된 JWT

Table 5. response-fields
Path Type Description

name

String

회원 이름

memberId

String

회원 번호

1.3. 회원 정보 수정

http-request
PATCH /users/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Content-Length: 68
Host: localhost:8080

{
  "memberId" : 1,
  "name" : "jeein Park",
  "password" : "1234"
}
Table 6. /users/{member-id}
Parameter Description

member-id

회원 식별자 ID

Table 7. request-fields
Path Type Description

name

String

이름

password

String

패스워드

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 99

{
  "data" : {
    "memberId" : 1,
    "email" : "jeein@gmail.com",
    "name" : "jeein Park"
  }
}

1.4. 회원 정보 조회

http-request
GET /users/1 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Host: localhost:8080
Table 8. /users/{member-id}
Parameter Description

member-id

회원 식별자 ID

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 99

{
  "data" : {
    "memberId" : 1,
    "email" : "jeein@gmail.com",
    "name" : "jeein Park"
  }
}

1.5. 회원 질문, 답변 정보 조회

http-request
GET /users/getInfo/1 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Host: localhost:8080
Table 9. /users/getInfo/{member-id}
Parameter Description

member-id

회원 식별자 ID

http-response
HTTP/1.1 302 Found
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 497

{
  "data" : {
    "questions" : [ {
      "id" : 1,
      "title" : "question1",
      "content" : "question1",
      "createdAt" : "2023-06-22T19:31:08.955164",
      "modifiedAt" : "2023-06-22T19:31:08.955167",
      "viewCount" : 1,
      "createdBy" : "jeein Park"
    } ],
    "answers" : [ {
      "answerId" : 1,
      "content" : "answer1",
      "createdAt" : "2023-06-22T19:31:08.955187",
      "modifiedAt" : "2023-06-22T19:31:08.955191",
      "createdBy" : "jeein Park"
    } ]
  }
}

1.6. 전체 회원 정보 조회

http-request
GET /users?page=1&size=10 HTTP/1.1
Accept: application/json
Host: localhost:8080
Table 10. request-parameters
Parameter Description

page

Page 번호

size

Page Size

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 294

{
  "data" : [ {
    "memberId" : 1,
    "email" : "jeein1@gmail.com",
    "name" : "Jeein Park1"
  }, {
    "memberId" : 2,
    "email" : "jeein2@gmail.com",
    "name" : "Jeein Park2"
  } ],
  "pageInfo" : {
    "page" : 1,
    "size" : 10,
    "totalElements" : 2,
    "totalPages" : 1
  }
}

1.7. 회원 탈퇴

http-request
DELETE /users/1 HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Host: localhost:8080
Table 11. /users/{member-id}
Parameter Description

member-id

회원 식별자 ID

http-response
HTTP/1.1 204 No Content
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN

1.8. 전체 회원 삭제

http-request
DELETE /users HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Host: localhost:8080
http-response
HTTP/1.1 204 No Content
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN

2. Question Controller

2.1. 질문 등록

http-request
POST /questions/ask HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Content-Length: 53
Host: localhost:8080

{
  "title" : "hello",
  "content" : "Hello World!"
}
request-body
{
  "title" : "hello",
  "content" : "Hello World!"
}
Table 12. request-fields
Path Type Description

title

String

질문 제목

content

String

질문 내용

http-response
HTTP/1.1 201 Created
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: /questions/1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Table 13. response-fields
Name Description

Location

등록된 질문의 URI. /question/{questionId}

2.2. 질문 수정

http-request
PATCH /questions/posts/1/edit HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Content-Length: 53
Host: localhost:8080

{
  "title" : "hello",
  "content" : "Hello World!"
}
Table 14. /questions/posts/{question-id}/edit
Parameter Description

question-id

질문 식별자 ID

request-body
{
  "title" : "hello",
  "content" : "Hello World!"
}
Table 15. request-fields
Path Type Description

title

String

질문 제목

content

String

질문 내용

http-response
HTTP/1.1 303 See Other
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: /questions/1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Table 16. response-fields
Name Description

Location

리다이렉트 URL /question/{questionId}

2.3. 질문 삭제

http-request
DELETE /questions/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Host: localhost:8080
Table 17. /questions/{question-id}
Parameter Description

question-id

질문 식별자 ID

http-response
HTTP/1.1 204 No Content
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN

2.4. 단일 질문 조회

http-request
GET /questions/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Table 18. /questions/{question-id}
Parameter Description

question-id

질문 식별자 ID

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 405

{
  "data" : {
    "id" : 1,
    "title" : "Title",
    "content" : "Content",
    "createdAt" : "2023-06-22T19:31:10",
    "modifiedAt" : "2023-06-22T19:31:10",
    "viewCount" : 0,
    "createdBy" : "user",
    "answers" : [ {
      "answerId" : 1,
      "content" : "body",
      "createdAt" : "2023-06-22T19:31:10",
      "modifiedAt" : "2023-06-22T19:31:10",
      "createdBy" : "kevin"
    } ]
  }
}
Table 19. response-fields
Path Type Description

data

Object

질문 리스트

data.id

Number

질문 식별자 ID

data.title

String

질문 제목

data.content

String

질문 내용

data.createdAt

String

질문 생성 시간

data.modifiedAt

String

질문 수정 시간

data.viewCount

Number

질문 조회 수

data.createdBy

String

질문 작성자

data.answers

Array

질문에 대한 답변 리스트

data.answers[].answerId

Number

답변 식별자 ID

data.answers[].content

String

답변 내용

data.answers[].createdAt

String

답변 생성 날짜

data.answers[].modifiedAt

String

답변 수정 날짜

data.answers[].createdBy

String

답변 작성자

2.5. 전체 질문 조회

http-request
GET /questions?size=10&page=1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Table 20. request-parameters
Parameter Description

page

페이지 번호

size

페이지 크기

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 482

{
  "data" : [ {
    "id" : 1,
    "title" : "Title",
    "content" : "Content",
    "viewCount" : 0,
    "createBy" : "user",
    "modifiedAt" : "2023-06-22T19:31:10",
    "answerCount" : 0
  }, {
    "id" : 2,
    "title" : "Title1",
    "content" : "Content1",
    "viewCount" : 0,
    "createBy" : "user",
    "modifiedAt" : "2023-06-22T19:31:10",
    "answerCount" : 0
  } ],
  "pageInfo" : {
    "page" : 1,
    "size" : 10,
    "totalElements" : 2,
    "totalPages" : 1
  }
}
Table 21. response-fields
Path Type Description

data

Array

질문 리스트

data[].id

Number

질문 식별자 ID

data[].title

String

질문 제목

data[].content

String

질문 내용

data[].modifiedAt

String

질문 수정 시간

data[].viewCount

Number

질문 조회 수

data[].answerCount

Number

질문에 대한 답변 개수

data[].createBy

String

질문 작성자

pageInfo

Object

페이지 정보

pageInfo.page

Number

현재 페이지 번호

pageInfo.size

Number

페이지 사이즈

pageInfo.totalElements

Number

전체 질문 갯수

pageInfo.totalPages

Number

전체 페이지 수

2.6. 제목 검색

http-request
GET /questions/search?size=10&page=1&title=Title HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Table 22. request-parameters
Parameter Description

page

페이지 번호

size

페이지 크기

title

찾을 질문 제목

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 482

{
  "data" : [ {
    "id" : 1,
    "title" : "Title",
    "content" : "Content",
    "viewCount" : 0,
    "createBy" : "user",
    "modifiedAt" : "2023-06-22T19:31:10",
    "answerCount" : 0
  }, {
    "id" : 2,
    "title" : "Title1",
    "content" : "Content1",
    "viewCount" : 0,
    "createBy" : "user",
    "modifiedAt" : "2023-06-22T19:31:10",
    "answerCount" : 0
  } ],
  "pageInfo" : {
    "page" : 1,
    "size" : 10,
    "totalElements" : 2,
    "totalPages" : 1
  }
}
Table 23. response-fields
Path Type Description

data

Array

질문 리스트

data[].id

Number

질문 식별자 ID

data[].title

String

질문 제목

data[].content

String

질문 내용

data[].modifiedAt

String

질문 수정 시간

data[].viewCount

Number

질문 조회 수

data[].answerCount

Number

질문에 대한 답변 개수

data[].createBy

String

질문 작성자

pageInfo

Object

페이지 정보

pageInfo.page

Number

현재 페이지 번호

pageInfo.size

Number

페이지 사이즈

pageInfo.totalElements

Number

전체 질문 갯수

pageInfo.totalPages

Number

전체 페이지 수


3. AnswerController

3.1. 답변 등록

http-request
POST /answers/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Content-Length: 27
Host: localhost:8080

{
  "content" : "answer1"
}
Table 24. /answers/{question-id}
Parameter Description

question-id

질문 식별자 ID

Table 25. request-fields
Path Type Description

content

String

답변 내용

http-response
HTTP/1.1 201 Created
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: /answers/1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Table 26. response-headers
Name Description

Location

Location header. 등록된 리소스의 URI

3.2. 답변 수정

http-request
PATCH /answers/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Content-Length: 45
Host: localhost:8080

{
  "answerId" : 1,
  "content" : "answer1"
}
Table 27. /answers/{answer-id}
Parameter Description

answer-id

답변 식별자 ID

Table 28. request-fields
Path Type Description

content

String

답변 내용

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 189

{
  "data" : {
    "answerId" : 1,
    "content" : "answer1",
    "createdAt" : "2023-06-22T19:31:05.665302",
    "modifiedAt" : "2023-06-22T19:31:05.665318",
    "createdBy" : "user"
  }
}

3.3. 답변 조회

http-request
GET /answers/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Table 29. /answers/{answer-id}
Parameter Description

answer-id

답변 식별자 ID

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 189

{
  "data" : {
    "answerId" : 1,
    "content" : "answer1",
    "createdAt" : "2023-06-22T19:31:05.703501",
    "modifiedAt" : "2023-06-22T19:31:05.703516",
    "createdBy" : "user"
  }
}

3.4. 전체 답변 조회

http-request
GET /answers?page=1&size=10 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Table 30. request-parameters
Parameter Description

page

페이지 번호

size

페이지 크기

http-response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 472

{
  "data" : [ {
    "answerId" : 1,
    "content" : "answer1",
    "createdAt" : "2023-06-22T19:31:05.248299",
    "modifiedAt" : "2023-06-22T19:31:05.248315",
    "createdBy" : "user1"
  }, {
    "answerId" : 2,
    "content" : "answer2",
    "createdAt" : "2023-06-22T19:31:05.248324",
    "modifiedAt" : "2023-06-22T19:31:05.248327",
    "createdBy" : "user2"
  } ],
  "pageInfo" : {
    "page" : 1,
    "size" : 10,
    "totalElements" : 2,
    "totalPages" : 1
  }
}

3.5. 답변 삭제

http-request
DELETE /answers/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJVU0VSIl0sInVzZ~
Host: localhost:8080
Table 31. /answers/{answer-id}
Parameter Description

answer-id

답변 식별자 ID

http-response
HTTP/1.1 204 No Content
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN