andela/codepirates-ah-backend

View on GitHub
src/routes/api/comment/doc.yml

Summary

Maintainability
Test Coverage

/comments/{slug}:
  post:
    summary: creates a comment on an article
    description: >
      creates a comment on an article
    tags:
      - Comment
    produces:
      - application/json
    parameters:
      - name: x-access-token
        in: header
        schema:
          type: string
        required:
          - authorization
      - name: slug
        in: path
        description: Slug for article 
        type: string
        required: true
      - name: body
        in: body
        description: comment data
        schema:
          $ref: '#definitions/Comment'
    responses:
      200:
        description: OK
        schema:
          $ref: '#definitions/Comment'
/comments/{id}:
  put:
    summary: Updates a comment
    description: >
      updates a specific comment
    tags:
      - Comment
    produces:
      - application/json
    parameters:
      - name: x-access-token
        in: header
        schema:
          type: string
        required:
          - authorization
      - name: id
        in: path
        description: id for article 
        type: string
        required: true
      - name: body
        in: body
        description: comment new data
        schema:
          $ref: '#definitions/Comment'
    responses:
      200:
        description: Comment successfully updated
        schema:
          $ref: '#definitions/Comment'
      400:
        $ref: '#responses/BadRequest'
  delete:
    summary: delete a specific comment
    tags:
      - Comment
    description: >
      deletes a particular comment
    produces:
      - application/json
    parameters:
      - name: x-access-token
        in: header
        schema:
          type: string
        required:
          - authorization
      - name: id
        in: path
        description: id for comment being deleted
        type: string
        required: true
    responses:
      200:
        description: Comment successfully deleted
        schema:
          $ref: '#definitions/Comment'
      400:
        $ref: '#/responses/BadRequest'
      404:
        $ref: '#/responses/Notfound' 
/comments:
  get:
    summary: get a comment
    description: >
      gets a specific comment
    tags:
      - Comment
    produces:
      - application/json
    parameters:
      - name: x-access-token
        in: header
        schema:
          type: string
        required:
          - authorization
    responses:
      200:
        description: Successfully retrieved comment
        schema:
          $ref: '#definitions/Comment'
      400:
        $ref: '#responses/BadRequest'
      404:
        $ref: '#/responses/Notfound'
/comments/like/{id}:
  get:
    summary: get all likes of a comment
    description: >
      gets a specific comment like
    tags:
      - Comment
    produces:
      - application/json
    parameters:
      - name: x-access-token
        in: header
        schema:
          type: string
        required:
          - authorization
    responses:
      200:
        description: Successfully retrieved comment likes
        schema:
          $ref: '#definitions/Comment'
      400:
        $ref: '#responses/BadRequest'
      404:
        $ref: '#/responses/Notfound'
  put:
    summary: unlike a specific comment
    description: >
      unlike a specific comment
    tags:
      - Comment
    produces:
      - application/json
    parameters:
      - name: x-access-token
        in: header
        schema:
          type: string
        required:
          - authorization
    responses:
      200:
        description: unlike a specific comment
        schema:
          $ref: '#definitions/Comment'
      400:
        $ref: '#responses/BadRequest'
      404:
        $ref: '#/responses/Notfound'
  post:
    summary: like a specific comment
    description: >
      like a specific comment
    tags:
      - Comment
    produces:
      - application/json
    parameters:
      - name: x-access-token
        in: header
        schema:
          type: string
        required:
          - authorization
    responses:
      200:
        description: like a specific comment
        schema:
          $ref: '#definitions/Comment'
      400:
        $ref: '#responses/BadRequest'
      404:
        $ref: '#/responses/Notfound'
tags:
- name: Comment
  description: Operations related to Comment
responses:
  success:
    description: Success
    schema:
      $ref: '#/definitions/Comment'
  BadRequest:
    description: Bad request
    schema:
      $ref: '#/definitions/Error'
  Notfound:
    description: Not found
    schema:
      $ref: '#/definitions/Error'
definitions:
  Comment:
    type: object
    properties:
      body:
        type: string
        description: comment body
      required:
      - body
  Error:
    type: object
    properties:
      status:
        type: string
        description: status code
      message:
        type: string
        description: description of error