openapi: 3.1.0
servers:
  - url: https://{tenant}
    variables:
      tenant:
        default: >-
          creativara--add-kitchen-api.wysiwyg.cloud.redocly.com/_mock/apis/kitchen
info:
  title: Kitchen API
  version: 1.0.0
security:
  - jwt: []
paths:
  /ingredients:
    post:
      summary: Create an ingredient.
      operationId: createIngredient
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Ingredient'
            examples:
              default_example:
                value:
                  kitchenId: altman-family
                  name: broccoli
                  quantity: 1.5
                  unit: cups
                  useBefore: '2019-08-24T14:15:22Z'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              example:
                id: 497f6eca-6276-4993-bfeb-53cbbbba6f08
                object: ingredient
                kitchenId: altman-family
                name: broccoli
                quantity: 1.5
                unit: cups
                useBefore: '2019-08-24T14:15:22Z'
                createdAt: '2019-08-24T14:15:22Z'
              schema:
                $ref: '#/components/schemas/IngredientResponse'
        '422':
          $ref: '#/components/responses/422'
    get:
      summary: Get ingredient list.
      operationId: getIngredientList
      responses:
        '200':
          description: Ingreditent list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngredientListResponse'
              example:
                object: list
                page:
                  endCursor: ZG9uJ3QgZGVjb2RlIG1l
                  startCursor: ZG9uJ3QgZGVjb2RlIG1l
                  hasNextPage: false
                  hasPrevPage: false
                  limit: 10
                  total: 0
                items:
                  - id: 497f6eca-6276-4993-bfeb-53cbbbba6f08
                    object: ingredient
                    kitchenId: altman-family
                    name: broccoli
                    quantity: 1.5
                    unit: cups
                    useBefore: '2019-08-24T14:15:22Z'
                    createdAt: '2019-08-24T14:15:22Z'
                total: 1
  /ingredients/{ingredientId}:
    parameters:
      - name: ingredientId
        in: path
        schema:
          type: string
    get:
      summary: Get ingredientId
      operationId: getIngredientInfo
      responses:
        '200':
          description: Ingredient info
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngredientResponse'
              example:
                id: 497f6eca-6276-4993-bfeb-53cbbbba6f08
                object: ingredient
                kitchenId: altman-family
                name: broccoli
                quantity: 1.5
                unit: cups
                useBefore: '2019-08-24T14:15:22Z'
                createdAt: '2019-08-24T14:15:22Z'
components:
  securitySchemes:
    jwt:
      description: |
        Generate your JWT when you log in.
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    Ingredient:
      type: object
      properties:
        kitchenId:
          type: string
        name:
          type: string
        quantity:
          type: number
        unit:
          type: string
        useBefore:
          type: string
          format: date
      required:
        - kitchenId
        - name
        - quantity
        - unit
    IngredientReadonly:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        object:
          type: string
          readOnly: true
        createdAt:
          type: string
          readOnly: true
    IngredientResponse:
      allOf:
        - $ref: '#/components/schemas/IngredientReadonly'
        - $ref: '#/components/schemas/Ingredient'
      unevaluatedProperties: false
    IngredientListResponse:
      type: object
      properties:
        object:
          type: string
        page:
          type: object
          properties:
            endCursor:
              type: string
            startCursor:
              type: string
            hasNextPage:
              type: boolean
            hasPrevPage:
              type: boolean
            limit:
              type: integer
            total:
              type: integer
        items:
          type: array
          items:
            $ref: '#/components/schemas/IngredientResponse'
        total:
          type: integer
  responses:
    '422':
      description: Failure.
      content:
        application/problem+json:
          example:
            message: >-
              Error validating body. data must have required property
              'kitchenId', data must have required property 'name', data must
              have required property 'quantity', data must have required
              property 'unit'
          schema:
            type: object
            properties:
              message:
                type: string
