Spring 게시판 2 - API spec

춤인형의 개발일지·2024년 12월 26일

Spring실습

목록 보기
3/40

24/12/23

게시판 만들기

api spec만들기

API spec?
API 스펙은 프론트엔드와 백엔드가 주고받을 데이터의 값 이름, URL, 메세지 등을 공통적으로 설계하는 부분이다.
❗Method, URL, Request, Response 4가지는 꼭 있어야한다.

API설계

- 게시판

  • 생성
    • POST
    • Path
      • /boards
    • Request (Body Parameters)
      • boardName String 게시판 이름
    • Response
      • boardName String 게시판 이름
      • boardId Long 게시판 아이디
  • 조회
    • GET
    • Path
      • /boards
    • Request: 전체 조회니까 X
    • Response
      • boardId Long 게시판 ID
      • boardName String 게시판 이름
  • 수정
    • PUT
    • Path
      • /boards/{boardId}
    • Request (Body Parameters)
      • boardName String 게시판 이름
      • boardId Long 게시판 아이디
    • Response
      • boardName String 게시판 이름
      • boardId Long 게시판 아이디
  • 삭제
    • DELETE
    • Path
      • /boards/{boardId}
    • Request (Path Segment Parameter)
      • boardId Long 게시판 ID
    • Response
      • data String 삭제된 게시판 ID

- 게시글

  • 생성
    • POST
    • Path
      • /posts
    • Request (Body Parameters)
      - title String 게시글 제목
      - content String 게시글 내용
    • Response
      • title String 게시글 제목
      • content String 게시글 내용
      • boardId Long 게시판 ID
  • 조회
    • GET
    • Path
      • /posts
    • Request Parameters: 전체 조회니까 필요 x
    • Response
      • title String 게시글 제목
      • content String 게시글 내용
      • boardId Long 게시판 ID
  • 수정
    • PUT
    • Path
      • /posts/{postId}
    • Request (Body Parameters)
      • title(or content)
    • Response
      • title(or content)
  • 삭제
    • DELETE
    • Path
      • /posts/{postId}
    • Request Parameters (Path Segment Parameter)
      • postId Long 게시글 ID
    • Response Message
      • String` 삭제된 게시글 ID

- 댓글

  • 생성
    • POST
    • Path
      • /comments
    • Request (Body Parameters)
      - content String 댓글 내용
    • Response Parameters
      - content String 댓글 내용
      - postId Long 게시글 ID
  • 조회
    • GET
    • Path
      • /comments
    • Request :전체 조회니까 x
    • Response
      - postId Long 게시글 ID
      - content String 댓글 내용
  • 수정
    - Put
    • Path
      • /comments/{commentId}
    • Request :
      • commentId Long 댓글 아이디
        • content String 댓글 내용
    • Response :
      • commentId Long 댓글 아이디
        • content String 댓글 내용
  • 삭제
    • DELETE
    • Path
      • /comments/{commentsId}
    • Request (Path Segment Parameter)
      - commentsId Number 댓글 ID
    • Response
      - data String 삭제된 댓글 ID

😐 느낀점

API는 중요하다. 처음부터 제대로 작성해야 코딩할때 헷갈리지 않게 할 수 있다.
처음부터 깊게 생각하지말고, 숲을 보고 나무로 들어가자
모든 어플에는 crud가 기본이다. API순서도 crud적으로 기능을 먼저 구현한 다음에 
세부적인 기능들을 구현할 수 있도록 하자

0개의 댓글