openapi: 3.0.3
info:
  title: Rentall API
  version: 1.0.0
  description: >-
    OpenAPI for Rentall Products and Rents endpoints.
servers:
  - url: https://rentall.cz
    description: Example server
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    Error:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              message: { type: string }
              field: { type: string, nullable: true }
    Product:
      type: object
      properties:
        id: { type: string }
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }
        internal_name: { type: string }
        basic:
          type: object
          properties:
            product_name: { type: string }
            product_desc: { type: string }
            location: { type: string }
            rent_owner:
              type: object
        additional:
          type: object
          properties:
            price: { type: number }
            caution: { type: number }
            time_unit: { type: string }
            selectedTerm:
              type: string
              description: References basic.rent_owner.terms.termsArray[].id
        settings:
          type: object
          properties:
            published: { type: boolean }
            slug: { type: string }
        gallery:
          type: object
        availability:
          type: object
    ProductList:
      type: object
      properties:
        docs:
          type: array
          items:
            $ref: '#/components/schemas/Product'
        page: { type: integer }
        totalPages: { type: integer }
        limit: { type: integer }
        hasNextPage: { type: boolean }
    Rent:
      type: object
      properties:
        id: { type: string }
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }
        basic:
          type: object
          properties:
            rentalName: { type: string }
            rentalContactPerson: { type: string }
            rentalPhone: { type: string }
            rentalEmail: { type: string }
            rentalIco: { type: string }
            rentalDic: { type: string, nullable: true }
            rentalStyle: { type: string }
        terms:
          type: object
          properties:
            termsArray:
              type: array
              items:
                type: object
                properties:
                  id: { type: string }
                  title: { type: string }
                  content: { type: string }
        products:
          type: object
          properties:
            productsList:
              type: object
              properties:
                docs:
                  type: array
                  items:
                    oneOf:
                      - type: string
                      - $ref: '#/components/schemas/Product'
                hasNextPage: { type: boolean }
        rentNameSystem: { type: string }
        email: { type: string }
    RentList:
      type: object
      properties:
        docs:
          type: array
          items:
            $ref: '#/components/schemas/Rent'
        page: { type: integer }
        totalPages: { type: integer }
        limit: { type: integer }
        hasNextPage: { type: boolean }
security:
  - bearerAuth: []
paths:
  /api/products:
    get:
      summary: List products
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: query
          name: page
          schema: { type: integer, default: 1 }
        - in: query
          name: limit
          schema: { type: integer, default: 10 }
        - in: query
          name: sort
          schema: { type: string }
        - in: query
          name: where
          schema: { type: string, description: JSON-encoded filter }
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductList'
        '401': { description: Unauthorized, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
        '403': { description: Forbidden, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
    post:
      summary: Create product
      security: [ { bearerAuth: [] } ]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Product'
      responses:
        '201': { description: Created, content: { application/json: { schema: { $ref: '#/components/schemas/Product' } } } }
        '400': { description: Bad Request, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
  /api/products/{id}:
    get:
      summary: Get product by ID
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Product' } } } }
        '404': { description: Not Found }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
    post:
      summary: Create or custom action on product by ID
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Product'
      responses:
        '200': { description: OK }
        '201': { description: Created }
        '400': { description: Bad Request }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
        '409': { description: Conflict }
    patch:
      summary: Update product
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Product'
      responses:
        '200': { description: OK }
        '400': { description: Bad Request }
        '404': { description: Not Found }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
    delete:
      summary: Delete product
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        '200': { description: OK }
        '204': { description: No Content }
        '404': { description: Not Found }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
  /api/rents:
    get:
      summary: List rents
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: query
          name: page
          schema: { type: integer, default: 1 }
        - in: query
          name: limit
          schema: { type: integer, default: 10 }
        - in: query
          name: sort
          schema: { type: string }
        - in: query
          name: where
          schema: { type: string, description: JSON-encoded filter }
      responses:
        '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/RentList' } } } }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
    post:
      summary: Create rent
      security: [ { bearerAuth: [] } ]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Rent'
      responses:
        '201': { description: Created, content: { application/json: { schema: { $ref: '#/components/schemas/Rent' } } } }
        '400': { description: Bad Request }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
  /api/rents/{id}:
    get:
      summary: Get rent by ID
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Rent' } } } }
        '404': { description: Not Found }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
    patch:
      summary: Update rent
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Rent'
      responses:
        '200': { description: OK }
        '400': { description: Bad Request }
        '404': { description: Not Found }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
    delete:
      summary: Delete rent
      security: [ { bearerAuth: [] } ]
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        '200': { description: OK }
        '204': { description: No Content }
        '404': { description: Not Found }
        '401': { description: Unauthorized }
        '403': { description: Forbidden }
