openapi: 3.0.3
info:
  title: Categories API
  description: API for managing categories
  version: 1.0.0
components:
  schemas:
    Categories:
      type: object
      required:
        - category
      properties:
        category:
          type: string
          description: The name of your category
        description:
          type: string
          description: The description of your category
tags:
  - name: Categories
    description: The categories managing API
paths:
  /category:
    get:
      summary: Lists all the categories
      tags: [Categories]
      responses:
        200:
          description: The list of the categories
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Categories'
        500:
          description: Some error happened
    post:
      summary: Create a new category
      tags: [Categories]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Categories'
      responses:
        201:
          description: The created category.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Categories'
        500:
          description: Some server error
  /category/{id}:
    get:
      summary: Get the category by id
      tags: [Categories]
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
          description: The category id
      responses:
        200:
          description: The category response by id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Categories'
        404:
          description: The category was not found
        500:
          description: Some error happened
    put:
      summary: Update the category by the id
      tags: [Categories]
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
          description: The category id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Categories'
      responses:
        201:
          description: The category was updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Categories'
        404:
          description: The category was not found
        500:
          description: Some error happened
    delete:
      summary: Remove the category by id
      tags: [Categories]
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
          description: The category id
      responses:
        200:
          description: The category was deleted
        404:
          description: The category was not found
        500:
          description: Some error happened
