openapi: 3.1.0
servers:
  - url: https://{server1}/v1
    variables:
      server1:
        enum:
          - cloud.kitchen.fake.com
        default: cloud.kitchen.fake.com
info:
  title: Kitchen API
  version: 1.0.0
  description: >-
    This is a sample Pet Store Server based on the OpenAPI 3.0 specification. 
    You can find out more about
tags:
  - name: ingredients
    description: Everything about your Ingredients
components:
  securitySchemes:
    jwtToken:
      type: apiKey
      name: authorization
      in: header
  schemas:
    page:
      type: object
      properties:
        endCursor:
          type: string
          description: Identifier of last ingridient in results.
          example: ZG9uJ3QgZGVjb2RlIG1l
        startCursor:
          type: string
          description: Identifier of first ingredient in results.
          example: ZG9uJ3QgZGVjb2RlIG1l
        hasNextPage:
          type: boolean
          description: Determinates if results have next page.
          example: true
        hasPrevPage:
          type: boolean
          description: Determinates if results have previous page.
          example: false
        limit:
          type: number
          description: Number of items return in single page.
          example: 100
        total:
          type: number
          description: Number of items in total.
          example: 100
      required:
        - endCursor
        - startCursor
        - hasNextPage
        - hasPrevPage
        - limit
        - total
    ingredient:
      type: object
      properties:
        id:
          type: string
          description: Identifier of ingredient.
          format: uuid
          readOnly: true
        object:
          type: string
          enum:
            - ingredient
          readOnly: true
        kitchenId:
          type: string
          example: altman-family
        name:
          type: string
          description: Name of ingredient.
          example: broccoli
        quantity:
          type: number
          description: Quantity of the ingredient.
          example: 10
        unit:
          type: string
          description: Unit of the ingredient.
          example: cups
        useBefore:
          type: string
          description: Expiration date of the ingredient.
          format: date-time
        createdAt:
          type: string
          description: Production date of the ingredient.
          readOnly: true
          format: date-time
      required:
        - id
        - object
        - kitchenId
        - name
        - quantity
        - unit
        - useBefore
        - createdAt
    unauthorized:
      type: object
      properties:
        title:
          type: string
          description: Summarized problem description.
          example: Unauthorized
        status:
          type: integer
          description: HTTP status code.
          enum:
            - 401
        detail:
          type: string
          description: More detail information about problem.
          example: You session already expired.
    bad-request:
      type: object
      properties:
        title:
          type: string
          description: Summarized problem description.
          example: Bad request
        status:
          type: integer
          description: HTTP status code.
          enum:
            - 400
        detail:
          type: string
          description: More detail information about problem.
          example: Quantity is to large.
    not-found:
      type: object
      properties:
        title:
          type: string
          description: Summarized problem description.
          example: Not found
        status:
          type: integer
          description: HTTP status code.
          enum:
            - 404
        detail:
          type: string
          description: More detail information about problem.
          example: Not found.
paths:
  /ingredients:
    get:
      tags:
        - ingriedients
      summary: List of ingriedients
      description: List of ingriedients used in kitchen.
      operationId: listIngriedients
      security:
        - jwtToken: []
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    enum:
                      - list
                  page:
                    $ref: '#/components/schemas/page'
                  total:
                    type: number
                    description: Number of items in total.
                    example: 100
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/ingredient'
                required:
                  - object
                  - page
                  - total
                  - items
        '401':
          description: Unauthorized
          content:
            application/json+problem:
              schema:
                $ref: '#/components/schemas/unauthorized'
    post:
      tags:
        - ingriedients
      summary: Add ingriedient
      description: Add ingriedient to kitchen.
      operationId: addIngriedient
      security:
        - jwtToken: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ingredient'
      responses:
        '201':
          description: Ingridient added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ingredient'
        '400':
          description: Invalid
          content:
            application/json+problem:
              schema:
                $ref: '#/components/schemas/bad-request'
        '401':
          description: Unauthorized
          content:
            application/json+problem:
              schema:
                $ref: '#/components/schemas/unauthorized'
  /ingredients/{id}:
    get:
      tags:
        - ingriedients
      summary: Get an ingriedient
      description: Get details about an ingredient.
      operationId: getIngriedient
      parameters:
        - name: id
          in: path
          schema:
            type: string
            format: uuid
      security:
        - jwtToken: []
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ingredient'
        '401':
          description: Unauthorized
          content:
            application/json+problem:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '404':
          description: Not found
          content:
            application/json+problem:
              schema:
                $ref: '#/components/schemas/not-found'
