openapi: 3.0.0
info:
  title: Architect API
  description: API Backend for Architect Website
  version: 1.0.0
servers:
  - url: http://localhost:5678/api/
paths:
  /users/login:
    post:
      summary: Log In the user.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: Connected
          content:
            application/json:
              schema:
                type: object
                properties:
                  userId:
                    type: integer
                    format: int64
                    example: 1
                  token:
                    type: string
                    example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTY1MTg3NDkzOSwiZXhwIjoxNjUxOTYxMzM5fQ.JGN1p8YIfR-M-5eQ-Ypy6Ima5cKA4VbfL2xMr2MgHm4
        '404':
          description: User not found
        '401':
          description: Not Authorized
  /categories:
    get:
      summary: Returns all categories
      responses:
        '200':
          description: Returns an array of all categories
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      format: int64
                      example: 1
                    name:
                      type: string
                      example: "Objets"
        '500':
          description: Unexpected Error
  /works:
    get:
      summary: Returns all works
      responses:
        '200':
          description: Returns an array of all works
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      format: int64
                      example: 1
                    title:
                      type: string
                      example: "Abajour Tahina"
                    imageUrl:
                      type: string
                      example: "http://localhost:5678/images/abajour-tahina1651286843956.png"
                    categoryId:
                      type: integer
                      format: int64
                      example: 1
                    userId:
                      type: integer
                      format: int64
                      example: 1
                    category:
                      type: object
                      properties:
                        id:
                          type: integer
                          format: int64
                          example: 1
                        name:
                          type: string
                          example: "Objets"
        '500':
          description: Unexpected Error
    post:
     summary: Send a new Work
     security:
       - BearerAuth: []

     requestBody:
       required: true
       content:
         multipart/form-data:
           schema:
             type: object
             properties:
               image:
                 type: string
                 format: binary
               title:
                 type: string
               category:
                 type: integer
                 format: int64
     responses:
       '201':
         description: Created
         content:
           application/json:
             schema:
               type: object
               properties:
                 id:
                   type: integer
                   format: int64
                 title:
                   type: string
                 imageUrl:
                   type: string
                 categoryId:
                   type: string
                 userId:
                   type: integer
                   format: int64
       '500':
         description: Unexpected Error
       '401':
         description: Unauthorized
       '400':
         description: Bad Request
  /works/{id}:
    delete:
     summary: Delete a work depending on id
     security:
       - BearerAuth: []
     parameters:
       - name: id
         in: path
         required: true
         description: id of work to be deleted
         schema:
           type: integer
           format: int64
           example: 1
     responses:
       '200':
         description: Item Deleted
       '401':
         description: Unauthorized
       '500':
         description: Unexpected Behaviour

components:
  securitySchemes:
   BearerAuth:
     type: http
     scheme: bearer
securityDefinitions:
  Bearer:
    type: JWT
    name: Authorization
    in: header
