openapi: 3.0.2
paths:

  /admin/categories:
    post:
      summary: Create a new category
      tags:
        - Categories

      security:
        - bearerAuth: []

      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCategory'

      responses:
        201:
          description: Category created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Category created successfully
                  category:
                    $ref: '#/components/schemas/CategoryResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

    get:
      summary: Retrieve a list of all categories
      tags:
        - Categories

      responses:
        200:
          description: A list of categories
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CategoryResponse'

        500:
          $ref: '#/components/responses/InternalServerError'

  /admin/categories/{id}:
    get:
      summary: Retrieve a category by ID
      tags:
        - Categories

      parameters:
        - $ref: '#/components/parameters/IdParameter'

      responses:
        200:
          description: A single category object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CategoryResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        404:
          $ref: '#/components/responses/NotFoundError'

        500:
          $ref: '#/components/responses/InternalServerError'

    put:
      summary: Update a category's information by ID
      tags:
        - Categories

      security:
        - bearerAuth: []

      parameters:
        - $ref: '#/components/parameters/IdParameter'

      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCategory'

      responses:
        200:
          description: Category updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Category updated successfully
                  category:
                    $ref: '#/components/schemas/CategoryResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        404:
          $ref: '#/components/responses/NotFoundError'

        500:
          $ref: '#/components/responses/InternalServerError'

    delete:
      summary: Delete a category by ID
      tags:
        - Categories

      security:
        - bearerAuth: []

      parameters:
        - $ref: '#/components/parameters/IdParameter'

      responses:
        200:
          description: Category deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Category deleted successfully
                  category:
                    $ref: '#/components/schemas/CategoryResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        404:
          $ref: '#/components/responses/NotFoundError'

        500:
          $ref: '#/components/responses/InternalServerError'
