openapi: 3.1.0
servers:
  - url: https://{tenant}.redoc.ly
    description: API server for kitchenApi
    variables:
      tenant:
        default: app
        description: The tenant name
info:
  title: Kitchen API
  version: 1.0.0
tags:
  - name: Ingredients
    description: Manage your kitchen ingredients
paths:
  /ingredients:
    get:
      operationId: getIngredients
      summary: Get all ingredients
      security:
        - jwt: []
      tags:
        - Ingredients
      responses:
        '200':
          description: Response for getting all ingredients
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    examples:
                      - list
                  page:
                    type: object
                    properties:
                      endCursor:
                        type: string
                        examples:
                          - ZG9uJ3QgZGVjb2RlIG1l
                      startCursor:
                        type: string
                        examples:
                          - ZG9uJ3QgZGVjb2RlIG1l
                      hasNextPage:
                        type: boolean
                        examples:
                          - false
                      hasPrevPage:
                        type: boolean
                        examples:
                          - false
                      limit:
                        type: integer
                        examples:
                          - 10
                      total:
                        type: integer
                        examples:
                          - 0
                    additionalProperties: false
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Ingredient'
                  total:
                    type: integer
                    examples:
                      - 1
                additionalProperties: false
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
    post:
      operationId: createIngredients
      summary: Add new ingredients
      security:
        - jwt: []
      tags:
        - Ingredients
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                kitchenId:
                  type: string
                  example: altman-family
                name:
                  type: string
                  example: broccoli
                quantity:
                  type: number
                  example: 2
                unit:
                  type: string
                  example: cups
                useBefore:
                  type: string
                  format: date-time
                  example: '2019-08-24T14:15:22Z'
              additionalProperties: false
              required:
                - kitchenId
                - name
                - quantity
                - unit
                - useBefore
      responses:
        '201':
          description: Response for adding new ingredient
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Ingredient'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
  /ingredients/{id}:
    get:
      operationId: getIngredient
      summary: Get single ingredient
      security:
        - jwt: []
      tags:
        - Ingredients
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: ID of the ingredient
      responses:
        '200':
          description: Response for getting a single ingredient
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Ingredient'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  securitySchemes:
    jwt:
      description: |
        Generate your JWT when you log in.
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    Ingredient:
      type: object
      properties:
        id:
          type: string
          format: uuid
          example: 497f6eca-6276-4993-bfeb-53cbbbba6f08
        object:
          type: string
          example: ingredient
        kitchenId:
          type: string
          example: altman-family
        name:
          type: string
          example: broccoli
        quantity:
          type: number
          example: 2
        unit:
          type: string
          example: cups
        useBefore:
          type: string
          format: date-time
          example: '2019-08-24T14:15:22Z'
        createdAt:
          type: string
          format: date-time
          example: '2019-08-24T14:15:22Z'
      additionalProperties: false
    Problem:
      type: object
      title: Problem
      properties:
        type:
          type: string
          format: uri-reference
          description: >
            URI reference that uniquely identifies the problem type only in the
            context of the provided API. Opposed to the specification in RFC
            9457 (formerly RFC 7807), it is neither recommended to be
            dereferenceable and point to a human-readable documentation nor
            globally unique for the problem type.
          default: about:blank
          example: /some/uri-reference
        title:
          type: string
          description: >
            Short summary of the problem type. Written in English and readable
            for engineers, usually not suited for non technical stakeholders and
            not localized.
          example: some title for the error situation
        status:
          type: integer
          format: int32
          description: >
            HTTP status code generated by the origin server for this occurrence
            of the problem.
          minimum: 100
          exclusiveMaximum: 600
          example: 400
        detail:
          type: string
          description: >
            Human readable explanation specific to this occurrence of the
            problem that is helpful to locate the problem and give advice on how
            to proceed. Written in English and readable for engineers, usually
            not suited for non technical stakeholders and not localized.
          example: some description for the error situation
        instance:
          type: string
          format: uri-reference
          description: >
            URI reference that identifies the specific occurrence of the
            problem, e.g. by adding a fragment identifier or sub-path to the
            problem type. May be used to locate the root of this problem in the
            source code.
          example: /some/uri-reference#specific-occurrence-context
        object:
          type: string
          enum:
            - problem
          example: problem
        errors:
          type: array
          description: >
            Additional information about the error situation. May be omitted if
            no additional information is available.
      required:
        - type
        - title
        - status
        - object
  responses:
    UnauthorizedError:
      description: User is not authorized to access this resource.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    ForbiddenError:
      description: Forbidden.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    NotFoundError:
      description: Resource not found.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
