[Sprint] REST API 문서 작성

블로그 애플리케이션 REST API 작성

⬛ 블로그에 필요한 데이터 모델을 디자인하세요. 블로그는 다음과 같은 기능을 필요로 합니다.

1. 조회 1. 블로그 글 전체 조회 2. 특정 블로그 글 조회 3. 모든 댓글 조회 4. 특정 댓글 조회 2. 생성 1. 새 블로그 글 생성 2. 새 댓글 생성 3. 삭제 1. 특정 블로그 글 삭제 2. 특정 댓글 삭제 4. 수정 1. 특정 블로그 글 수정 2. 특정 댓글 수정

Article

Comment

⬛ 스프레드시트로 작성한 데이터 모델을 Sheety와 연동하세요.

⬛ API 문서화를 진행하세요.

데이터 모델 디자인

components:
  schemas:
    Article:
      type: object
      required:
        - id
        - author_id
        - title
        - share_type
        - view_count
        - write_date
        - modify_date
      properties:
        id:
          type: string
          example: 'AR00001'
        author_id:
          type: string
          example: 'U000001'
        title:
          type: string
          example: 'This is Title'
        content:
          type: string
          example: 'Today practice is fun!!'
        category_id:
          type: string
          example: 'C00001'
        share_type:
          type: string
          example: 'ALL'
        view_count:
          type: integer
          example: 5
        write_date:
          type: string
          example: '2023-03-23 11:50:01'
        modify_date:
          type: string
          example: '2023-03-23 14:01:05'    
    Comment:
      type: object
      required:
        - id
        - article_id
        - author_id
        - content
        - favorite_count
        - declaration_yn
        - blind_yn
        - delete_yn
        - write_date
        - modify_date
      properties:
        id:
          type: string
          example: 'CM00001' 
        article_id:
          type: string
          example: 'AR00001'
        upper_comment_id:
          type: string
          example: ''
        author_id:
          type: string
          example: 'U000002'
        content:
          type: string
          example: 'This is good article!!'
        favorite_count:
          type: integer
          example: 3
        declaration_yn:
          type: string
          example: 'Y'
        blind_yn:
          type: string
          example: 'Y'
        delete_yn:
          type: string
          example: 'N'
        write_date:
          type: string
          example: '2023-03-23 12:30:01'   
        modify_date:
          type: string
          example: '2023-03-23 15:01:05'

URI Path 디자인

paths:
  /article:
    get:
      description: 'Inquiry All Article'
      parameters:
        - in: query
          name: author_id
          required: true
          schema:
            type: string  
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  article:
                    type: array
                    items:
                      $ref: '#/components/schemas/Article'
    post:
      description: 'Create Article'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Article'
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  article:
                    $ref: '#/components/schemas/Article'
  /article/{id}:
    get:
      description: 'Inquiry Specipic Article'
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string    
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  article:
                    $ref: '#/components/schemas/Article'
    put:
      description: 'Modify Article'
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Article'
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  article:
                    $ref: '#/components/schemas/Article'
    delete:
      description: 'Delete Article'
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 'Success'
  /comment:
    get:
      description: 'Inquiry All Comment'
      parameters:
        - in: query
          name: article_id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  comment:
                    $ref: '#/components/schemas/Comment'
    post:
      description: 'Create Comment'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Comment'
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  comment:
                    $ref: '#/components/schemas/Comment'
  /comment/{id}:
    get:
      description: 'Inquiry Specipic Comment'
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  comment:
                    $ref: '#/components/schemas/Comment'
       
    put:
      description: 'Modify Comment'
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Comment'
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  comment:
                    $ref: '#/components/schemas/Comment'
    delete:
      description: 'Delete Comment'
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 'Success'

⬛ Swagger를 사용하여 API를 테스트하세요.

블로그 글 전체 조회

새 블로그 글 작성

블로그 글 삭제

특정 블로그 글 조회

블로그 글 수정

모든 댓글 조회

특정 댓글 조회

새 댓글 작성

특정 댓글 수정

특정 댓글 삭제

Leave a Comment