openapi: '3.1.0'

info:

  title: HortiApi

  version: 3.0.0-rc.81

  description: |-
    Definition of the HortiApi, OpenAPI 3.1-compliant YAML document describing horticultural API endpoints.
    Visit [https://hortiapi.com](https://hortiapi.com) for details.

    Note: Server-Sent Events (SSE) endpoints are described using OpenAPI 3.2 semantics.
    This does not affect runtime behavior, but some viewers may not fully reflect SSE details.

    Some useful links:
    - [hortiapi.com](https://hortiapi.com)
    - [github.com/hortiapi](https://github.com/hortiapi)
    - [rapidocweb.com](https://rapidocweb.com)
    - [swagger.io](https://swagger.io)
  
  termsOfService: https://hortiapi.com/terms-of-service
  
  contact:
    name: Michael Lakerveld
    email: apiteam@hortiapi.com
    url: https://hortiapi.com/

  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html

externalDocs:
  description: Find out more about HortiApi
  url: https://hortiapi.com

servers:
  - url: http://localhost/horti-api/v3
  - url: https://v3.sandbox.hortiapi.net
  - url: https://v3.hortiapi.net
  - url: https://api.ai2.nl/v3

tags:
  - name: Article
    description: |
      Definitions of products including classification, names
      and other relevant properties.

  - name: Catalog
    description: |
      Create, modify and search for catalog items which can be used as the 
      template for stock or orderlines.

  - name: Company
    description: |
      Lookup and search for companies active in the horticulture sector,
      including their identifiers and types.

  - name: Data
    description: |
      Lookup generic structured reference data such as countries, currencies, 
      and units used throughout the API.

  - name: Discovery
    description: |
      Provides a machine-readable capability and protocol description of this HortiAPI server.
      This endpoint enables dynamic client configuration and multi-vendor interoperability
      by exposing which API modules and protocols are supported by this implementation.

  - name: Document
    description: |
      Create and manage documents such as invoices and delivery notes linked
      to entities in the system.

  - name: Facility
    description: |
      Lookup and manage facilities operated by a company, such as warehouses,
      production sites or distribution centers, used in logistics and stock flows.

  - name: Feature
    description: |
      Characteristics that define article variations, such as stem length,
      number of buds, or flower color.

  - name: Good
    description: |
      Physical goods within facilities, representing concrete instances of
      articles as they are stored, handled or moved through logistics processes.

  - name: Invoice
    description: |
      Create, modify and search for invoices between trading parties,
      including amounts, taxes, payment references and processing states.

  - name: Me
    description: |
      Details about the authenticated user, including linked companies
      and applications with granted access.

  - name: Order
    description: |
      Create, modify and search for orders between customers and suppliers that
      describe delivery and payment conditions.

  - name: OrderLine
    description: |
      Create, modify and search for orderlines that describe specific articles,
      quantities, pricing and other options.

  - name: Stock
    description: |
      Create, modify and search for stock availability already in storage or 
      in transit and check product specifications.

  - name: Supply
    description: |
      Real-time availability of products offered by growers or suppliers,
      used to place, update or cancel orders and track state changes.

  - name: User
    description: |
      Lookup and search for users active in the horticulture sector,
      including their identifiers and companies.

paths:

# article

  /article:

    post:
      tags:
        - Article
      operationId: HAPI3ArticleUpdate
      summary: Create or update article
      description: |-
        Create a new article when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Article'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Article'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Article'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /article/{articleId}:

    get:
      tags:
        - Article
      operationId: HAPI3ArticleGet
      summary: Get article by ID
      description: |-
        Retrieve the details of the article with the specified `articleId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: articleId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Article'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Article
      operationId: HAPI3ArticleDelete
      summary: Delete article by ID
      description: |-
        Remove the article identified by `articleId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: articleId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /article/search:

    post:
      tags:
        - Article
      operationId: HAPI3ArticleSearch
      summary: Search article items
      description: |-
        Find articles matching given criteria (e.g. name, group, code).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ArticleFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Article'
            text/event-stream:
              description: Server-Sent Events stream with article updates
              itemSchema:
                $ref: '#/components/schemas/ArticleSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# catalog

  /catalog:

    post:
      tags:
        - Catalog
      operationId: HAPI3CatalogUpdate
      summary: Create or update catalog
      description: |-
        Create a new catalog when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Catalog'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Catalog'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Catalog'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /catalog/{catalogId}:

    get:
      tags:
        - Catalog
      operationId: HAPI3CatalogGet
      summary: Get catalog by ID
      description: |-
        Retrieve the details of the catalog with the specified `catalogId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: catalogId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Catalog'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Catalog
      operationId: HAPI3CatalogDelete
      summary: Delete catalog by ID
      description: |-
        Remove the catalog identified by `catalogId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: catalogId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /catalog/search:

    post:
      tags:
        - Catalog
      operationId: HAPI3CatalogSearch
      summary: Search catalog items
      description: |-
        Find catalog items matching given criteria (e.g. product, kind, features).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Catalog'
            text/event-stream:
              description: Server-Sent Events stream with catalog updates
              itemSchema:
                $ref: '#/components/schemas/CatalogSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# company

  /company:

    post:
      tags:
        - Company
      operationId: HAPI3CompanyUpdate
      summary: Create or update company
      description: |-
        Create a new company when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Company'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Company'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Company'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /company/{companyId}:

    get:
      tags:
        - Company
      operationId: HAPI3CompanyGet
      summary: Get company by ID
      description: |-
        Retrieve the details of the company with the specified `companyId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: companyId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Company'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Company
      operationId: HAPI3CompanyDelete
      summary: Delete company by ID
      description: |-
        Remove the company identified by `companyId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: companyId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /company/search:

    post:
      tags:
        - Company
      operationId: HAPI3CompanySearch
      summary: Search companies
      description: |-
        Find companies matching given criteria (e.g. kind, gln, name).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompanyFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Company'
            text/event-stream:
              description: Server-Sent Events stream with company updates
              itemSchema:
                $ref: '#/components/schemas/CompanySseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# data

  /data:

    post:
      tags:
        - Data
      operationId: HAPI3DataUpdate
      summary: Create or update data
      description: |-
        Create a new data when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Data'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Data'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Data'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /data/{dataId}:

    get:
      tags:
        - Data
      operationId: HAPI3DataGet
      summary: Get data by ID
      description: |-
        Retrieve the details of the data with the specified `dataId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: dataId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Data'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Data
      operationId: HAPI3DataDelete
      summary: Delete data by ID
      description: |-
        Remove the data identified by `dataId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: dataId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /data/search:

    post:
      tags:
        - Data
      operationId: HAPI3DataSearch
      summary: Search data items
      description: |-
        Find data matching given criteria (e.g. kind, ...).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Data'
            text/event-stream:
              description: Server-Sent Events stream with data updates
              itemSchema:
                $ref: '#/components/schemas/DataSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# discovery

  /discovery:
    get:
      tags:
        - Discovery
      operationId: HAPI3DiscoveryGet
      summary: Get discovery document
      description: |-
        Retrieve the details of this api implementation.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HortiApiDiscoveryDocument'


# document

  /document:

    post:
      tags:
        - Document
      operationId: HAPI3DocumentUpdate
      summary: Create or update document
      description: |-
        Create a new document when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Document'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /document/{documentId}:

    get:
      tags:
        - Document
      operationId: HAPI3DocumentGet
      summary: Get document by ID
      description: |-
        Retrieve the details of the document with the specified `documentId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: documentId
          required: true
          schema: 
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Document
      operationId: HAPI3DocumentDelete
      summary: Delete document by ID
      description: |-
        Remove the document identified by `documentId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: documentId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /document/{documentId}/download:

    get:
      tags:
        - Document
      operationId: HAPI3DocumentDownload
      summary: Download document by ID
      description: |-
         Retrieve the file of the document with the specified `documentId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: documentId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
        - in: query
          name: authkey
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/octet-stream:
                schema:
                  type: string
                  format: binary
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /document/search:

    post:
      tags:
        - Document
      operationId: HAPI3DocumentSearch
      summary: Search documents
      description: |-
        Find documents matching given criteria (e.g. kind, ...).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Document'
            text/event-stream:
              description: Server-Sent Events stream with document updates
              itemSchema:
                $ref: '#/components/schemas/DocumentSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# facility

  /facility:

    post:
      tags:
        - Facility
      operationId: HAPI3FacilityUpdate
      summary: Create or update a facility
      description: |-
        Create a new facility when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Facility'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Facility'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Facility'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /facility/{facilityId}:

    get:
      tags:
        - Facility
      operationId: HAPI3FacilityGet
      summary: Get facility by ID
      description: |-
        Retrieve the details of the facility with the specified `facilityId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: facilityId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Facility'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Facility
      operationId: HAPI3FacilityDelete
      summary: Delete facility by ID
      description: |-
        Remove the facility identified by `facilityId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: facilityId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /facility/search:

    post:
      tags:
        - Facility
      operationId: HAPI3FacilitySearch
      summary: Search facilities
      description: |-
        Find facilities matching given criteria (e.g. ...).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FacilityFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Facility'
            text/event-stream:
              description: Server-Sent Events stream with facility updates
              itemSchema:
                $ref: '#/components/schemas/FacilitySseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# feature

  /feature:

    post:
      tags:
        - Feature
      operationId: HAPI3FeatureUpdate
      summary: Create or update feature
      description: |-
        Create a new feature when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Feature'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /feature/{featureId}:

    get:
      tags:
        - Feature
      operationId: HAPI3FeatureGet
      summary: Get feature by ID
      description: |-
        Retrieve the details of the feature with the specified `featureId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: featureId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Feature
      operationId: HAPI3FeatureDelete
      summary: Delete feature by ID
      description: |-
        Remove the feature identified by `featureId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: featureId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /feature/search:

    post:
      tags:
        - Feature
      operationId: HAPI3FeatureSearch
      summary: Search feature items
      description: |-
        Find features matching given criteria (e.g. name, group, code).
      parameters:
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Feature'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# good

  /good:

    post:
      tags:
        - Good
      operationId: HAPI3GoodUpdate
      summary: Create or update a good
      description: |-
        Create a new good when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Good'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Good'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Good'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /good/{goodId}:

    get:
      tags:
        - Good
      operationId: HAPI3GoodGet
      summary: Get good by ID
      description: |-
        Retrieve the details of the good with the specified `goodId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: goodId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Good'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Good
      operationId: HAPI3GoodDelete
      summary: Delete good by ID
      description: |-
        Remove the good identified by `goodId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: goodId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /good/search:

    post:
      tags:
        - Good
      operationId: HAPI3GoodSearch
      summary: Search goods
      description: |-
        Find goods matching given criteria (e.g. ...).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GoodFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Good'
            text/event-stream:
              description: Server-Sent Events stream with good updates
              itemSchema:
                $ref: '#/components/schemas/GoodSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# invoice

  /invoice:

    post:
      tags:
        - Invoice
      operationId: HAPI3InvoiceUpdate
      summary: Create or update invoice
      description: |-
        Create a new invoice when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Invoice'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /invoice/{invoiceId}:

    get:
      tags:
        - Invoice
      operationId: HAPI3InvoiceGet
      summary: Get invoice by ID
      description: |-
        Retrieve the details of the invoice with the specified `invoiceId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: invoiceId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Invoice
      operationId: HAPI3InvoiceDelete
      summary: Delete invoice by ID
      description: |-
        Remove the invoice identified by `invoiceId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: invoiceId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /invoice/search:

    post:
      tags:
        - Invoice
      operationId: HAPI3InvoiceSearch
      summary: Search invoices
      description: |-
        Find invoices matching given criteria (e.g. date range, state, customer).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Invoice'
            text/event-stream:
              description: Server-Sent Events stream with invoice updates
              itemSchema:
                $ref: '#/components/schemas/InvoiceSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# me

  /me:

    get:
      tags:
        - Me
      operationId: HAPI3MeGet
      summary: Get identity
      description: |-
        Retrieve the identity tied to the provided API token, returning the authenticated user’s details—including applications, companies and defined resources.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Me'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/InternalServerError'


# order

  /order:

    post:
      tags:
        - Order
      operationId: HAPI3OrderUpdate
      summary: Create or update order
      description: |-
        Create a new order when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Order'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /order/{orderId}:

    get:
      tags:
        - Order
      operationId: HAPI3OrderGet
      summary: Get order by ID
      description: |-
        Retrieve the details of the order with the specified `orderId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: orderId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
        - in: query
          name: includeLines
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Order
      operationId: HAPI3OrderDelete
      summary: Delete order by ID
      description: |-
        Remove the order identified by `orderId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: orderId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /order/search:

    post:
      tags:
        - Order
      operationId: HAPI3OrderSearch
      summary: Search orders
      description: |-
        Find orders matching given criteria (e.g. date range, state, customer).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Order'
            text/event-stream:
              description: Server-Sent Events stream with order updates
              itemSchema:
                $ref: '#/components/schemas/OrderSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# order-line

  /order-line:

    post:
      tags:
        - OrderLine
      operationId: HAPI3OrderLineUpdate
      summary: Create or update orderline
      description: |-
        Create a new orderline when no `id` is supplied; update existing when `id` is present.
        The orderId is used to determine the order to which the orderline belongs.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderLine'
        # text/json
        # application/*+json
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderLine'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderLine'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /order-line/{orderLineId}:

    get:
      tags:
        - OrderLine
      operationId: HAPI3OrderLineGet
      summary: Get orderline by ID
      description: |-
        Retrieve the details of the orderline with the specified `orderLineId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: orderLineId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderLine'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - OrderLine
      operationId: HAPI3OrderLineDelete
      summary: Delete orderline by ID
      description: |-
        Remove the orderline identified by `orderLineId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: orderLineId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /order-line/search:

    post:
      tags:
        - OrderLine
      operationId: HAPI3OrderLineSearch
      summary: Search orderlines
      description: |-
        Find orderlines matching given criteria (e.g. orderId, state, customer).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderLineFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/OrderLine'
            text/event-stream:
              description: Server-Sent Events stream with orderline updates
              itemSchema:
                $ref: '#/components/schemas/OrderLineSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# stock

  /stock:

    post:
      tags:
        - Stock
      operationId: HAPI3StockUpdate
      summary: Create or update stock
      description: |-
        Create a new stock when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Stock'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stock'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stock'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /stock/{stockId}:

    get:
      tags:
        - Stock
      operationId: HAPI3StockGet
      summary: Get stock by ID
      description: |-
        Retrieve the details of the stock with the specified `stockId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: stockId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stock'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - Stock
      operationId: HAPI3StockDelete
      summary: Delete stock by ID
      description: |-
        Remove the stock identified by `stockId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: stockId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /stock/search:

    post:
      tags:
        - Stock
      operationId: HAPI3StockSearch
      summary: Search stock items
      description: |-
        Find stock items matching given criteria (e.g. product, kind, features).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StockFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Stock'
            text/event-stream:
              description: Server-Sent Events stream with stock updates
              itemSchema:
                $ref: '#/components/schemas/StockSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# supply

  /supply:

    post:
      tags:
        - Supply
      operationId: HAPI3SupplyObserve
      summary: Observe supply stream
      description: |-
        Retreive a (live) supply stream identified by `streamId` from the system.
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SupplyFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SupplyEvent'
            text/event-stream:
              description: Server-Sent Events stream with supply updates
              itemSchema:
                $ref: '#/components/schemas/SupplySseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /supply/order:

    post:
      tags:
        - Supply
      operationId: HAPI3SupplyOrder
      summary: Order supply from a supply stream
      description: |-
        Order supply from a supply stream. When no `id` is supplied, a new supply order is created; when `id` is present, the existing supply order is returned.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SupplyOrder'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SupplyOrder'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /supply/transaction/search:

    post:
      tags:
        - Supply
      operationId: HAPI3SupplyTransactionSearch
      summary: Search supply transactions
      description: |-
        Find supply transactions matching given criteria (e.g. date, kind, buyer, supplier).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SupplyTransactionFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SupplyTransaction'
            text/event-stream:
              description: Server-Sent Events stream with supplytransaction updates
              itemSchema:
                 $ref: '#/components/schemas/SupplyTransactionSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'


# user

  /user:

    post:
      tags:
        - User
      operationId: HAPI3UserUpdate
      summary: Create or update user
      description: |-
        Create a new user when no `id` is supplied; update existing when `id` is present.
      parameters:
        - $ref: '#/components/parameters/idempotency-key'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /user/{userId}:

    get:
      tags:
        - User
      operationId: HAPI3UserGet
      summary: Get user by ID
      description: |-
        Retrieve the details of the user with the specified `userId`. If not found, a 404 error will be returned.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: userId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

    delete:
      tags:
        - User
      operationId: HAPI3UserDelete
      summary: Delete user by ID
      description: |-
        Remove the user identified by `userId` from the system.
      parameters:
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
        - in: path
          name: userId
          required: true
          schema:
            $ref: '#/components/schemas/Id'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'

  /user/search:

    post:
      tags:
        - User
      operationId: HAPI3UserSearch
      summary: Search users
      description: |-
        Find users matching given criteria (e.g. ...).
        Returns 'application/json' by default. Returns 'text/event-stream' when the request includes Accept 'text/event-stream'.
      parameters:
        - $ref: '#/components/parameters/last-event-id'
        - $ref: '#/components/parameters/prefer'
        - $ref: '#/components/parameters/x-company-id'
        - $ref: '#/components/parameters/x-facility-id'
        - $ref: '#/components/parameters/x-language'
        - $ref: '#/components/parameters/x-language-mode'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserFilter'
      responses:
        '200':
          description: OK
          headers:
            Preference-Applied:
              $ref: '#/components/headers/preference-applied'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
            text/event-stream:
              description: Server-Sent Events stream with user updates
              itemSchema:
                $ref: '#/components/schemas/UserSseEvent'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '410':
          $ref: '#/components/responses/GoneError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          $ref: '#/components/responses/NotImplemented'



components:

  parameters:

    x-company-id:
      name: x-company-id
      in: header
      required: false
      description: The company ID to use when a user has access rights for multiple companies.
      schema:
        $ref: '#/components/schemas/Id'

    x-facility-id:
      name: x-facility-id
      in: header
      required: false
      description: The facility ID to use when a user has access rights for multiple facilities.
      schema:
        $ref: '#/components/schemas/Id'

    x-language:
      name: x-language
      in: header
      required: false
      description: |
        Preferred language code (e.g., `nl`, `en`, `de`, `fr`) to use when serializing `Texts` fields.
        If provided, the server will try to return content in the requested language.
        If not provided or if the requested language is unavailable, the server may fall back
        to a default language or return multiple language values depending on the chosen `x-language-mode`.
      schema:
        type: string
        example: en

    x-language-mode:
      name: x-language-mode
      in: header
      required: false
      description: |
        Controls how `Texts` fields are serialized in the response.
        Possible values are defined in the `LanguageMode` schema:
        - `default`: Let the server decide the most appropriate format.
        - `value`: Return only the text value as a plain string.
        - `text`: Return a single object containing both language code and value.
        - `texts`: Return an array of objects for multiple languages.
        Can be combined with `x-language` to fine-tune language selection and output format.
      schema:
        $ref: '#/components/schemas/LanguageMode'

    idempotency-key:
      name: Idempotency-Key
      in: header
      required: false
      description: |
        Unique key to ensure idempotent processing of POST requests.
        Repeated requests with the same key return the original response.
      schema:
        type: string
        maxLength: 255

    last-event-id:
      name: Last-Event-ID
      in: header
      required: false
      description: Resume SSE stream from last received event id
      schema:
        type: string

    prefer:
      name: Prefer
      in: header
      required: false
      description: |
        RFC 7240 Prefer. HortiApi supports:
        - max-results=<n> : limit number of returned items
      schema:
        type: string
      example: "max-results=200"

  headers:
    preference-applied:
      description: Indicates which Prefer directives were applied.
      schema:
        type: string
      example: "max-results"

  schemas:

    Address:
      required:
        - type
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        type:
          $ref: '#/components/schemas/AddressType'
        gln:
          type: string
        hub:
          type: string
          description: gln of the hub where the address is located or empty if there is none
        addressLines:
          type: array
          items:
            type: string
        postalCode:
          type: string
        place:
          type: string
        state:
          type: string
        countryCode:
          type: string
        countryName:
          type: string
        phone:
          type: string
        email:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    AddressType:
      enum:
        - unknown
        - default
        - physical
        - postal
        - delivery
      type: string

    Amount:
      required:
        - value
      type: object
      properties:
        value:
          format: decimal
          type: number
          example: 1.75
        currency:
          type: string
          default: EUR
      additionalProperties: false

    Application:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        value:
          type: string
          default: ''
          example: 'Application XYZ'
      additionalProperties: false

    Article:
      type: [object, 'null']
      properties:
        id:
          $ref: '#/components/schemas/Id'
        list:
          $ref: '#/components/schemas/ArticleList'
        code:
          type: [string, 'null']
          description: ID of the article assigned by the industry such as 'VBN code'
          example: '27157'
        group:
          $ref: '#/components/schemas/ArticleGroup'
        groupCode:
          type: [string, 'null']
          description: ID of the article group assigned by the industry system such as 'VBN group'
          example: '10100101'
        name:
          $ref: '#/components/schemas/Texts'
          # example: 'Rosa grootbloemig Red Naomi!'
        tradeName:
          type: string
          example: 'R GR RED NAOMI!'
        genus:
          type: [string, 'null']
          example: 'Rosa'
        species:
          type: [string, 'null']
        cultivar:
          type: [string, 'null']
        features:
          type: array
          items:
            $ref: '#/components/schemas/ItemFeature'
        regulatoryFeatures:
          type: array
          items:
            $ref: '#/components/schemas/ArticleRegulatoryFeature'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    ArticleSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Article'
      additionalProperties: false

    ArticleFeaturePrescription:
      enum:
        - empty
        - required
        - recommended
        - allowed
      type: string
      example: 'required'
      default: 'empty'

    ArticleFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        list:
          $ref: '#/components/schemas/ArticleList'
        code:
          type: string
          default: ''
          example: '27157'
        name:
          type: string
          default: ''
          example: 'Red Naomi'
        tradeName:
          type: string
          default: ''
          example: 'RED NAOMI'
        group:
          $ref: '#/components/schemas/ArticleGroup'
        groupCode:
          type: string
          default: ''
          example: '10100101'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    ArticleGroup:
      enum:
        - none

        # core
        - cut-flowers
        - house-plants
        - garden-plants

        # bouquets/arrangements
        - bouquets
        - house-plant-arrangements
        - garden-plant-arrangements

        # other
        - cut-foliage
        - decorative-materials
        - bulbs
        - packaging-materials

        # artificial
        - artificial-flowers
        - artificial-plants

      type: string
      example: 'cut-flowers'
      default: 'none'

    ArticleList:
      enum:
        - vbn
        - plu
        - cn
        - custom
      type: string
      default: vbn
      example: vbn

    ArticleRegulatoryFeature:
      required:
        - f
        - p
      type: object
      properties:
        f:
          type: string
          example: 'S20'
          default: ''
        p:
          $ref: '#/components/schemas/ArticleFeaturePrescription'
      additionalProperties: false

    Catalog:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this catalog item, is a Resource of type [catalog/kind](https://hortiapi.com/resource/catalog/kind)
          type: string
          default: ''
          x-resource: catalog/kind
          externalDocs:
            url: https://hortiapi.com/resource/catalog/kind
        state:
          description: State of this catalog, is a Resource of type [catalog/state](https://hortiapi.com/resource/catalog/state)
          type: string
          default: ''
          x-resource: catalog/state
          externalDocs:
            url: https://hortiapi.com/resource/catalog/state
        action:
          description: Action for this catalog, is a Resource of type [catalog/action](https://hortiapi.com/resource/catalog/action)
          type: string
          default: ''
          x-resource: catalog/action
          externalDocs:
            url: https://hortiapi.com/resource/catalog/action
        supplier:
          $ref: '#/components/schemas/Party'
        product:
          $ref: '#/components/schemas/Product'
        article:
          $ref: '#/components/schemas/Article'
        packings:
          type: [array, 'null']
          items:
            $ref: '#/components/schemas/Packing'
        prices:
          type: array
          items:
            $ref: '#/components/schemas/Price'
        references:
          type: array
          items:
            $ref: '#/components/schemas/Reference'
        notes:
          type: array
          items:
            $ref: '#/components/schemas/Note'
        photos:
          type: array
          items:
            $ref: '#/components/schemas/PhotoUrl'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    CatalogSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Catalog'
      additionalProperties: false

    CatalogFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this catalog item, is a Resource of type [catalog/kind](https://hortiapi.com/resource/catalog/kind)
          type: string
          default: ''
          x-resource: catalog/kind
          externalDocs:
            url: https://hortiapi.com/resource/catalog/kind
        state:
          description: State of the catalog, is a Resource of type [catalog/state](https://hortiapi.com/resource/catalog/state)
          type: [string, 'null']
          default: ''
          x-resource: catalog/state
          externalDocs:
            url: https://hortiapi.com/resource/catalog/state
        manufacturer:
          $ref: '#/components/schemas/Party'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Charge:
      oneOf:
        - $ref: '#/components/schemas/AmountCharge'
        - $ref: '#/components/schemas/PercentageCharge'
      discriminator:
        propertyName: kind
        mapping:
          amount: '#/components/schemas/AmountCharge'
          percentage: '#/components/schemas/PercentageCharge'
      description: Extra charge.

    ChargeBase:
      type: object
      required:
        - id
        - kind
        - target
        - source
        - destination
        - description
        - rate
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          $ref: '#/components/schemas/ChargeKind'
        target:
          $ref: '#/components/schemas/ChargeTarget'
        source:
          $ref: '#/components/schemas/ChargeSource'
        destination:
          $ref: '#/components/schemas/ChargeDestination'
        description:
          type: string
        rate:
          $ref: '#/components/schemas/ValueAddedTaxRate'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    AmountCharge:
      allOf:
        - $ref: '#/components/schemas/ChargeBase'
        - type: object
          required:
            - amount
          properties:
            kind:
              type: string
              enum:
                - amount
            amount:
              $ref: '#/components/schemas/Amount'
          additionalProperties: false

    PercentageCharge:
      allOf:
        - $ref: '#/components/schemas/ChargeBase'
        - type: object
          required:
            - percentage
          properties:
            kind:
              type: string
              enum:
                - percentage
            percentage:
              type: number
              format: decimal
              description: Percentage value, for example 12.5 means 12.5%.
          additionalProperties: false

    ChargeKind:
      type: string
      enum:
        - amount
        - percentage

    ChargeDestination:
      type: string
      enum:
        - charge-line
        - include-in-product-price

    Charges:
      description: Array with charge objects
      type: [array, 'null']
      items:
        $ref: '#/components/schemas/Charge'

    ChargeSource:
      type: string
      enum:
        - net-amount
        - orders
        - order-lines
        - units
        - pieces

    ChargeTarget:
      type: string
      enum:
        - invoice
        - order
        - order-line
        - stock

    Classification:
      type: object
      properties:
        system:
          type: string
          default: ''
          description: Classification system (SystemId)
          example: 'CBS'
        value:
          type: string
          default: ''
          description: Classification code (ClassCode)
          example: '06031100'
      additionalProperties: false

    Company:
      required:
        - kind
        - role
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        role:
          description: Role of this company, is a Resource of type [company/role](https://hortiapi.com/resource/company/role)
          type: string
          default: ''
          x-resource: company/role
          externalDocs:
            url: https://hortiapi.com/resource/company/role
        kind:
          description: Kind of this company, is a Resource of type [company/kind](https://hortiapi.com/resource/company/kind)
          type: string
          default: ''
          x-resource: company/kind
          externalDocs:
            url: https://hortiapi.com/resource/company/kind
        code:
          type: string
        name:
          type: string
        legalName:
          type: string
        email:
          type: string
        logo:
          type: string
        addresses:
          type: array
          items:
            $ref: '#/components/schemas/Address'
        users:
          type: array
          items:
            $ref: '#/components/schemas/CompanyUser'
        facilities:
          type: array
          items:
            $ref: '#/components/schemas/CompanyFacility'
        contacts:
          type: array
          items:
            $ref: '#/components/schemas/CompanyContact'
        registrations:
          type: array
          items:
            $ref: '#/components/schemas/CompanyRegistration'
        applications:
          type: array
          items:
            $ref: '#/components/schemas/CompanyApplication'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    CompanyApplication:
      required:
        - isDefault
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    CompanyContact:
      required:
        - kind
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this company contact, is a Resource of type [company-contact/kind](https://hortiapi.com/resource/company-contact/kind)
          type: string
          default: ''
          x-resource: company-contact/kind
          externalDocs:
            url: https://hortiapi.com/resource/company-contact/kind
        name:
          type: [string, 'null']
        function:
          type: [string, 'null']
        email:
          type: [string, 'null']
        phone:
          type: [string, 'null']
      additionalProperties: false

    CompanyFacility:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    CompanyFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        role:
          description: Role of this company, is a Resource of type [company/role](https://hortiapi.com/resource/company/role)
          type: [string, 'null']
          default: ''
          x-resource: company/role
          externalDocs:
            url: https://hortiapi.com/resource/company/role
        kind:
          description: Kind of this company, is a Resource of type [company/kind](https://hortiapi.com/resource/company/kind)
          type: [string, 'null']
          default: ''
          x-resource: company/kind
          externalDocs:
            url: https://hortiapi.com/resource/company/kind
        code:
          type: string
        gln:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    CompanyRegistration:
      type: object
      properties:
        kind:
          description: Kind of this company registration, is a Resource of type [company-registration/kind](https://hortiapi.com/resource/company-registration/kind)
          type: string
          default: ''
          x-resource: company-registration/kind
          externalDocs:
            url: https://hortiapi.com/resource/company-registration/kind
        tradeName:
          type: string
        gln:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    CompanySseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Company'
      additionalProperties: false

    CompanyUser:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Data:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this data, is a Resource of type [data/kind](https://hortiapi.com/resource/data/kind)
          type: [string, 'null']
          default: ''
          x-resource: data/kind
          externalDocs:
            url: https://hortiapi.com/resource/data/kind
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    DataSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Data'
      additionalProperties: false

    DataFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this data, is a Resource of type [data/kind](https://hortiapi.com/resource/data/kind)
          type: [string, 'null']
          default: ''
          x-resource: data/kind
          externalDocs:
            url: https://hortiapi.com/resource/data/kind
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Delivery:
      type: object
      properties:
        terms:
          $ref: '#/components/schemas/Incoterms'
        tradeLocation:
          $ref: '#/components/schemas/Location'
        latestOrder:
          format: date-time
          type: [string, 'null']
        earliestDispatch:
          format: date-time
          type: [string, 'null']
        latestDispatch:
          format: date-time
          type: [string, 'null']
        earliestDelivery:
          format: date-time
          type: [string, 'null']
        latestDelivery:
          format: date-time
          type: [string, 'null']
        deliveryLocation:
          $ref: '#/components/schemas/Location'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Document:
      required:
        - kind
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        owner:
          type: string
        kind:
          description: Kind of this document, is a Resource of type [document/kind](https://hortiapi.com/resource/document/kind)
          type: string
          x-resource: document/kind
          externalDocs:
            url: https://hortiapi.com/resource/document/kind
        title:
          type: string
        createdAt:
          format: date-time
          type: string
        createdBy:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    DocumentSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Document'
      additionalProperties: false

    DocumentFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        owner:
          type: string
        kind:
          description: Kind of this document, is a Resource of type [document/kind](https://hortiapi.com/resource/document/kind)
          type: [string, 'null']
          default: ''
          x-resource: document/kind
          externalDocs:
            url: https://hortiapi.com/resource/document/kind
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    DocumentLink:
      description: Reference to a Document on the /document endpoint. Server-populated and informational, values supplied by a client are ignored.
      required:
        - id
        - kind
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of the referenced document, is a Resource of type [document/kind](https://hortiapi.com/resource/document/kind)
          type: string
          x-resource: document/kind
          externalDocs:
            url: https://hortiapi.com/resource/document/kind
        title:
          type: string
        date:
          format: date-time
          type: string
      additionalProperties: false

    Facility:
      type: [object, 'null']
      properties:
        id:
          $ref: '#/components/schemas/Id'
        company:
          $ref: '#/components/schemas/Id'
        # role:
        #   description: Role of this facility, is a Resource of type [facility/role](https://hortiapi.com/resource/facility/role)
        #   type: string
        #   default: ''
        #   x-resource: facility/role
        #   externalDocs:
        #     url: https://hortiapi.com/resource/facility/role
        capability:
          description: Capabilities of this facility, is a Resource of type [facility/capability](https://hortiapi.com/resource/facility/capability)
          type: string
          default: ''
          x-resource: facility/capability
          externalDocs:
            url: https://hortiapi.com/resource/facility/capability
        name:
          type: string
        addresses:
          type: array
          items:
            $ref: '#/components/schemas/Address'
        companies:
          type: array
          items:
            $ref: '#/components/schemas/FacilityCompany'
        users:
          type: array
          items:
            $ref: '#/components/schemas/FacilityUser'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    FacilityCompany:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    FacilityFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        capabilities:
          description: Capabilities of a facility, is a Resource of type [facility/capability](https://hortiapi.com/resource/facility/capability)
          type: string
          default: ''
          x-resource: facility/capability
          externalDocs:
            url: https://hortiapi.com/resource/facility/capability
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    FacilitySseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Facility'
      additionalProperties: false

    FacilityUser:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Feature:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        list:
          $ref: '#/components/schemas/ArticleList'
        type:
          type: string
          default: ''
          example: 'S20'
        description:
          $ref: '#/components/schemas/Texts'
          # example: 'Minimum length of flower stem'
        values:
          type: array
          description: The available values for this feature
          items:
            $ref: '#/components/schemas/FeatureValue'
      additionalProperties: false

    FeatureFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        list:
          $ref: '#/components/schemas/ArticleList'
        type:
          type: string
          default: ''
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    FeatureValue:
      type: object
      properties:
        value:
          type: string
          default: ''
          example: '060'
        description:
          $ref: '#/components/schemas/Texts'
          # example: '60 cm'
      additionalProperties: false

    Good:
      type: [object, 'null']
      properties:
        id:
          $ref: '#/components/schemas/Id'
        owner:
          type: string
          default: ''
          description: Id of the owner of the goods
        facility:
          type: string
          default: ''
          description: Id of the facility that may contain, will contain, or has contained the goods, or empty to use the default
        source:
          type: string
          default: ''
          description: Id of the source from which this good is derived. A good can represent a partial quantity of a stock or orderline.
        state:
          description: State of this good, is a Resource of type [good/state](https://hortiapi.com/resource/good/state)
          type: string
          default: ''
          x-resource: good/state
          externalDocs:
            url: https://hortiapi.com/resource/good/state
        action:
          description: Action for this good, is a Resource of type [good/action](https://hortiapi.com/resource/good/action)
          type: string
          default: ''
          x-resource: good/action
          externalDocs:
            url: https://hortiapi.com/resource/good/action
        product:
          $ref: '#/components/schemas/Product'
        article:
          $ref: '#/components/schemas/Article'
        quantity:
          $ref: '#/components/schemas/Quantity'
        packing:
          $ref: '#/components/schemas/Packing'
        prices:
          type: array
          items:
            $ref: '#/components/schemas/Price'
        references:
          type: array
          items:
            $ref: '#/components/schemas/Reference'
        notes:
          type: array
          items:
            $ref: '#/components/schemas/Note'
        relatedGoods:
          type: array
          items:
            $ref: '#/components/schemas/Good'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    GoodSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Good'
      additionalProperties: false

    GoodFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        stock:
          type: string
        facility:
          type: string
        state:
          description: State of this good, is a Resource of type [good/state](https://hortiapi.com/resource/good/state)
          type: string
          default: ''
          x-resource: good/state
          externalDocs:
            url: https://hortiapi.com/resource/good/state
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    HortiApiDiscoveryDocument:
      type: object
      additionalProperties: false
      required:
        - schemaVersion
        - service
        - issuer
        - apiBaseUrl
        - version
        - openapi
        - capabilities
#
      properties:
        schemaVersion:
          type: integer
          minimum: 1
          description: Version of this discovery document schema.
          example: 1
        service:
          type: string
          description: Product/service name of the implementation.
          example: HortiAPI
        issuer:
          type: string
          format: uri
          description: Canonical issuer/base identity URL for this server.
          example: https://example-company.com
        apiBaseUrl:
          type: string
          format: uri
          description: Base URL where the API is served.
          example: https://example-company.com/horti-api/v3
        version:
          type: string
          description: Implementation build/service version (may include prerelease identifiers).
          example: 3.0.0-rc.199
        openapi:
          type: string
          format: uri
          description: URL to the OpenAPI document for this server.
          example: https://example-company.com/horti-api/v3/hortiapi-v3.yaml
        status:
          type: string
          description: Important status message about the server (show the end-user).
        capabilities:
          type: array
          minItems: 0
          description: List of capability declarations supported by this server.
          items:
            $ref: "#/components/schemas/HortiApiCapability"

    HortiApiCapability:
      type: object
      additionalProperties: false
      required:
        - apiVersion
        - name
        - enabled
        - protocols
        - resources
      properties:
        name:
          type: string
          description: Capability/module name/endpoint prefix.
          example: stock
        enabled:
          type: boolean
          description: Whether this capability is enabled on this server.
        status:
          type: string
          description: Important status message about the capability (show the end-user).
        protocols:
          $ref: "#/components/schemas/HortiApiCapabilityProtocols"
        resources:
          $ref: '#/components/schemas/Resources'

    HortiApiCapabilityProtocols:
      type: object
      additionalProperties: false
      properties:
        sse:
          type: boolean
          description: Whether this capability supports SSE.

    Id:
        type: [string, 'null']
        description: ID of the entity. A 128‑bit GUID (UUID) encoded in Base64‐URL (RFC 4648 §5), without "+" or "/" (uses "-" and "_"), no padding, exactly 22 characters.
        example: ''
        pattern: '^[A-Za-z0-9_-]{22}$'

    Incoterms:
      enum:
        - undefined
        - exw
        - fca
        - fas
        - fob
        - cpt
        - cfr
        - cif
        - cip
        - dpu
        - dap
        - ddp
      type: string
      default: 'undefined'
      example: 'ddp'

    Invoice:
      required:
        - date
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        state:
          description: State of this invoice, is a Resource of type [invoice/state](https://hortiapi.com/resource/invoice/state)
          type: string
          default: ''
          x-resource: invoice/state
          externalDocs:
            url: https://hortiapi.com/resource/invoice/state
        kind:
          description: Kind of this invoice, is a Resource of type [invoice/kind](https://hortiapi.com/resource/invoice/kind)
          type: string
          x-resource: invoice/kind
          externalDocs:
            url: https://hortiapi.com/resource/invoice/kind
        action:
          description: Action for this invoice, is a Resource of type [invoice/action](https://hortiapi.com/resource/invoice/action)
          type: string
          default: ''
          x-resource: invoice/action
          externalDocs:
            url: https://hortiapi.com/resource/invoice/action
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        date:
          format: date-time
          type: string
        description:
          type: string
          default: ''
        orders:
          type: [array, 'null']
          items:
            $ref: '#/components/schemas/Order'
        charges:
          $ref: '#/components/schemas/Charges'
        documents:
          type: [array, 'null']
          items:
            $ref: '#/components/schemas/DocumentLink'
        total:
          $ref: '#/components/schemas/Totals'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    InvoiceSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Invoice'
      additionalProperties: false

    InvoiceFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        state:
          description: State of this invoice, is a Resource of type [invoice/state](https://hortiapi.com/resource/invoice/state)
          type: [string, 'null']
          default: ''
          x-resource: invoice/state
          externalDocs:
            url: https://hortiapi.com/resource/invoice/state
        kind:
          description: Kind of this invoice, is a Resource of type [invoice/kind](https://hortiapi.com/resource/invoice/kind)
          type: [string, 'null']
          x-resource: invoice/kind
          externalDocs:
            url: https://hortiapi.com/resource/invoice/kind
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        dateFrom:
          format: date-time
          type: [string, 'null']
        dateTill:
          format: date-time
          type: [string, 'null']
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    ItemFeature:
      type: object
      properties:
        type:
          type: string
          default: ''
          example: 'S20'
        value:
          type: string
          default: ''
          example: '060'
      additionalProperties: false

    LanguageMode:
      description: |
        Defines how multilingual text values are serialized in JSON.
        Possible values:
        - `default`: Let the server choose the most appropriate format.
        - `value`: Serialize as a plain string.
        - `text`: Serialize as a single object with language code and value.
        - `texts`: Serialize as an array of objects for multiple languages.
      enum:
        - default
        - value
        - text
        - texts
      type: string
      default: 'default'
      example: 'value'
      x-enum-descriptions:
        - Let the server choose the most appropriate format.
        - Serialize as a plain string (single language, no metadata).
        - Serialize as a single object with language code and value.
        - Serialize as an array of objects for multiple languages.

    Location:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        gln:
          type: string
          default: '8714231208631'
        name:
          type: string
          default: ''
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Me:
      type: object
      description: Identity of the api-token, user information, available companies, available endpoints
      properties:
        application:
          $ref: '#/components/schemas/MeApplication'
        companies:
          type: array
          description: The available companies for this user
          items:
            $ref: '#/components/schemas/MeCompany'
        company:
          $ref: '#/components/schemas/MeCompany'
        facilities:
          type: array
          description: The available facilities for this user
          items:
            $ref: '#/components/schemas/MeFacility'
        facility:
          $ref: '#/components/schemas/MeFacility'
        user:
          $ref: '#/components/schemas/MeUser'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    MeApplication:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    MeCompany:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        applications:
          type: array
          items:
            $ref: '#/components/schemas/MeApplication'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    MeFacility:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    MeUser:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Measurement:
      type: object
      required: [type, value, unit]
      properties:
        type:
          $ref: '#/components/schemas/MeasurementType'
        value:
          type: number
          format: decimal
        unit:
          $ref: '#/components/schemas/Unit'

    MeasurementType:
      type: string
      description: Type of physical measurement. grossWeight = weight including packaging (bruto), netWeight = weight of the product only (netto), length/height/depth = package dimensions
      enum:
        - grossWeight
        - netWeight
        - length
        - height
        - width

    Note:
      type: object
      properties:
        code:
          type: string
          default: ''
        value:
          type: string
          default: ''
      additionalProperties: false

    Order:
      required:
        - orderDate
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        state:
          description: State of this order, is a Resource of type [order/state](https://hortiapi.com/resource/order/state)
          type: string
          default: ''
          x-resource: order/state
          externalDocs:
            url: https://hortiapi.com/resource/order/state
        kind:
          description: Kind of this order, is a Resource of type [order/kind](https://hortiapi.com/resource/order/kind)
          type: string
          x-resource: order/kind
          externalDocs:
            url: https://hortiapi.com/resource/order/kind
        action:
          description: Action for this order, is a Resource of type [order/action](https://hortiapi.com/resource/order/action)
          type: string
          default: ''
          x-resource: order/action
          externalDocs:
            url: https://hortiapi.com/resource/order/action
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        orderDate:
          format: date-time
          type: string
        dispatchDate:
          format: date-time
          type: string
        deliveryDate:
          format: date-time
          type: string
        invoiceDate:
          format: date-time
          type: string
        description:
          type: string
          default: ''
        lines:
          type: [array, 'null']
          items:
            $ref: '#/components/schemas/OrderLine'
        charges:
          $ref: '#/components/schemas/Charges'
        documents:
          type: [array, 'null']
          items:
            $ref: '#/components/schemas/DocumentLink'
        total:
          $ref: '#/components/schemas/Totals'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    OrderSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Order'
      additionalProperties: false

    OrderFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        state:
          description: State of the orders, is a Resource of type [order/state](https://hortiapi.com/resource/order/state)
          type: [string, 'null']
          default: ''
          x-resource: order/state
          externalDocs:
            url: https://hortiapi.com/resource/order/state
        kind:
          description: Kind of the orders, is a Resource of type [order/kind](https://hortiapi.com/resource/order/kind)
          type: [string, 'null']
          x-resource: order/kind
          externalDocs:
            url: https://hortiapi.com/resource/order/kind
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        orderDateFrom:
          format: date-time
          type: [string, 'null']
        orderDateTill:
          format: date-time
          type: [string, 'null']
        shipDateFrom:
          format: date-time
          type: [string, 'null']
        shipDateTill:
          format: date-time
          type: [string, 'null']
        invoiceDateFrom:
          format: date-time
          type: [string, 'null']
        invoiceDateTill:
          format: date-time
          type: [string, 'null']
        # description:
        #   type: string
        #   default: ''
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    OrderLine:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        order:
          type: string
          default: ''
          description: Id of the order containing the orderline, or empty to use the default
        state:
          description: State of this orderline, is a Resource of type [order-line/state](https://hortiapi.com/resource/order-line/state)
          type: string
          default: ''
          x-resource: order-line/state
          externalDocs:
            url: https://hortiapi.com/resource/order-line/state
        kind:
          description: Kind of this orderline, is a Resource of type [order-line/kind](https://hortiapi.com/resource/order-line/kind)
          type: string
          default: ''
          x-resource: order-line/kind
          externalDocs:
            url: https://hortiapi.com/resource/order-line/kind
        action:
          description: Action for this orderline, is a Resource of type [order-line/action](https://hortiapi.com/resource/order-line/action)
          type: string
          default: ''
          x-resource: order-line/action
          externalDocs:
            url: https://hortiapi.com/resource/order-line/action
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        product:
          $ref: '#/components/schemas/Product'
        article:
          $ref: '#/components/schemas/Article'
        quantity:
          $ref: '#/components/schemas/Quantity'
        packing:
          $ref: '#/components/schemas/Packing'
        price:
          $ref: '#/components/schemas/Price'
        charges:
          $ref: '#/components/schemas/Charges'
        references:
          type: array
          items:
            $ref: '#/components/schemas/Reference'
        notes:
          type: array
          items:
            $ref: '#/components/schemas/Note'
        photos:
          type: array
          items:
            $ref: '#/components/schemas/PhotoUrl'
        delivery:
          $ref: '#/components/schemas/Delivery'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    OrderLineSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/OrderLine'
      additionalProperties: false

    OrderLineFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        order:
          type: [string, 'null']
          default: ''
          description: Id of the order for the orderlines
        state:
          description: State of the orderlines, is a Resource of type [order-line/state](https://hortiapi.com/resource/order-line/state)
          type: [string, 'null']
          default: ''
          x-resource: order-line/state
          externalDocs:
            url: https://hortiapi.com/resource/order-line/state
        kind:
          description: Kind of the orderlines, is a Resource of type [order-line/kind](https://hortiapi.com/resource/order-line/kind)
          type: [string, 'null']
          x-resource: order-line/kind
          externalDocs:
            url: https://hortiapi.com/resource/order-line/kind
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Package:
      required:
        - quantity
      type: [object, 'null']
      properties:
        code:
          type: string
          default: ''
        quantity:
          format: decimal
          type: number
          default: 1
        measurements:
          type: array
          items:
            $ref: '#/components/schemas/Measurement'
      additionalProperties: false

    Packing:
      type: object
      properties:
        bunch:
          $ref: '#/components/schemas/Package'
        bundle:
          $ref: '#/components/schemas/Package'
        box:
          $ref: '#/components/schemas/Package'
        layer:
          $ref: '#/components/schemas/Package'
        carrier:
          $ref: '#/components/schemas/Package'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Party:
      type: [object, 'null']
      properties:
        id:
          $ref: '#/components/schemas/Id'
        gln:
          type: string
          example: '8718288056689'
        name:
          type: string
          example: 'Company ABC'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    PhotoUrl:
      type: object
      properties:
        url:
          type: string
          example: 'https://hortiapi.com/photos/1234567890.jpg'
      additionalProperties: false

    Price:
      required:
        - type
      type: object
      properties:
        type:
          $ref: '#/components/schemas/PriceType'
        amount:
          $ref: '#/components/schemas/Amount'
        minimum:
          $ref: '#/components/schemas/Quantity'
        maximum:
          $ref: '#/components/schemas/Quantity'
      additionalProperties: false

    PriceType:
      enum:
        - invoice
        - provisional
        - consumer
        - clock-reference
        - clock-minimal
      type: string
      default: 'invoice'
      example: 'invoice'

    Product:
      required:
        - type
      type: object
      properties:
        industryId:
          type: [string, 'null']
          description: ID of the article assigned by the industry such as 'VBN code'
          example: '27157'
          default: '1999'
        supplierId:
          type: [string, 'null']
          description: ID of the article assigned by the supplier
          example: null
        customerId:
          type: [string, 'null']
          description: ID of the article assigned by the customer
          example: 'my-rosa-code-1'
        manufacturerId:
          type: [string, 'null']
          description: ID of the article assigned by the manufacturer
          example: 'RGRNAOMI80'
        type:
          $ref: '#/components/schemas/ProductType'
        description:
          $ref: '#/components/schemas/Texts'
        features:
          type: array
          items:
            $ref: '#/components/schemas/ItemFeature'
        classifications:
          type: array
          items:
            $ref: '#/components/schemas/Classification'
        manufacturer:
          $ref: '#/components/schemas/Party'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    ProductType:
      enum:
        - product
        - logisticMeans
        - service
        - hardware
      type: string
      example: 'product'
      default: 'product'

    Quantity:
      required:
        - unit
        - value
      type: [object, 'null']
      properties:
        unit:
          $ref: '#/components/schemas/UnitCode'
        value:
          format: decimal
          type: number
          default: 0
          example: 1
      additionalProperties: false

    Reference:
      description: Reference to a related document or transaction, as a name/value pair. Comparable to ReferencedDocument in UN/CEFACT and the RFF segment in EDIFACT.
      type: object
      properties:
        name:
          type: string
          default: ''
        value:
          type: string
          default: ''
      additionalProperties: false

    Resources:
      description: Array with resource identifiers
      externalDocs:
        url: https://hortiapi.com/resource/
      type: [array, 'null']
      example: 
      - 'custom/name:value1'
      - 'custom/name:value2'
      items:
        type: string
        description: Resource identifier
        pattern: '^([a-zA-Z0-9\-]+/[a-zA-Z0-9\-]+):([a-zA-Z0-9\-@.?=]+(,[a-zA-Z0-9\-@.?=]+)*)$'

    StreamEventType:
        enum:
            - reset
            - add
            - update
            - delete
            - live
        type: string
        default: 'add'
        example: 'add'

    Stock:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this stock item, is a Resource of type [stock/kind](https://hortiapi.com/resource/stock/kind)
          type: string
          default: ''
          x-resource: stock/kind
          externalDocs:
            url: https://hortiapi.com/resource/stock/kind
        state:
          description: State of this stock, is a Resource of type [stock/state](https://hortiapi.com/resource/stock/state)
          type: string
          default: ''
          x-resource: stock/state
          externalDocs:
            url: https://hortiapi.com/resource/stock/state
        action:
          description: Action for this stock item, is a Resource of type [stock/action](https://hortiapi.com/resource/stock/action)
          type: string
          default: ''
          x-resource: stock/action
          externalDocs:
            url: https://hortiapi.com/resource/stock/action
        supplier:
          $ref: '#/components/schemas/Party'
        product:
          $ref: '#/components/schemas/Product'
        article:
          $ref: '#/components/schemas/Article'
        quantity:
          $ref: '#/components/schemas/Quantity'
        packing:
          $ref: '#/components/schemas/Packing'
        prices:
          type: array
          items:
            $ref: '#/components/schemas/Price'
        charges:
          $ref: '#/components/schemas/Charges'
        references:
          type: array
          items:
            $ref: '#/components/schemas/Reference'
        notes:
          type: array
          items:
            $ref: '#/components/schemas/Note'
        photos:
          type: array
          items:
            $ref: '#/components/schemas/PhotoUrl'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    StockSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Stock'
      additionalProperties: false

    StockFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this stock item, is a Resource of type [stock/kind](https://hortiapi.com/resource/stock/kind)
          type: string
          default: ''
          x-resource: stock/kind
          externalDocs:
            url: https://hortiapi.com/resource/stock/kind
        state:
          description: State of the stock, is a Resource of type [stock/state](https://hortiapi.com/resource/stock/state)
          type: [string, 'null']
          default: ''
          x-resource: stock/state
          externalDocs:
            url: https://hortiapi.com/resource/stock/state
        manufacturer:
          $ref: '#/components/schemas/Party'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Supply:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        state:
          description: State of this supply, is a Resource of type [supply/state](https://hortiapi.com/resource/supply/state)
          type: string
          default: ''
          x-resource: supply/state
          externalDocs:
            url: https://hortiapi.com/resource/supply/state
        supplier:
          $ref: '#/components/schemas/Party'
        product:
          $ref: '#/components/schemas/Product'
        article:
          $ref: '#/components/schemas/Article'
        quantity:
          $ref: '#/components/schemas/Quantity'
        packings:
          type: [array, 'null']
          items:
            $ref: '#/components/schemas/Packing'
        prices:
          type: array
          items:
            $ref: '#/components/schemas/Price'
        references:
          type: array
          items:
            $ref: '#/components/schemas/Reference'
        notes:
          type: array
          items:
            $ref: '#/components/schemas/Note'
        photos:
          type: array
          items:
            $ref: '#/components/schemas/PhotoUrl'
        deliveries:
          type: array
          items:
            $ref: '#/components/schemas/Delivery'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    SupplyEvent:
      type: object
      required:
        - event
        - data
      properties:
        id:
          type: string
          description: event id
        event:
          $ref: '#/components/schemas/StreamEventType'
        data:
          $ref: '#/components/schemas/Supply'
      additionalProperties: false

    SupplySseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        id:
          type: string
          description: SSE event id
        event:
          $ref: '#/components/schemas/StreamEventType'
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/Supply'
      additionalProperties: false

    SupplyFilter:
      required:
        - streamId
      type: object
      properties:
        streamId:
          $ref: '#/components/schemas/Id'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    SupplyOrder:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        streamId:
          $ref: '#/components/schemas/Id'
        supply:
          $ref: '#/components/schemas/Id'
        state:
          description: State of this supply order, is a Resource of type [supply-order/state](https://hortiapi.com/resource/supply-order/state)
          type: string
          default: ''
          x-resource: supply-order/state
          externalDocs:
            url: https://hortiapi.com/resource/supply-order/state
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        product:
          $ref: '#/components/schemas/Product'
        article:
          $ref: '#/components/schemas/Article'
        quantity:
          $ref: '#/components/schemas/Quantity'
        packing:
          $ref: '#/components/schemas/Packing'
        price:
          $ref: '#/components/schemas/Price'
        references:
          type: array
          items:
            $ref: '#/components/schemas/Reference'
        notes:
          type: array
          items:
            $ref: '#/components/schemas/Note'
        photos:
          type: array
          items:
            $ref: '#/components/schemas/PhotoUrl'
        delivery:
          $ref: '#/components/schemas/Delivery'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    SupplyTransaction:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        date:
          format: date-time
          type: string
        state:
          description: State of this transaction, is a Resource of type [supply-transaction/state](https://hortiapi.com/resource/supply-transaction/state)
          type: string
          default: ''
          x-resource: supply-transaction/state
          externalDocs:
            url: https://hortiapi.com/resource/supply-transaction/state
        interactions:
          type: array
          items:
            $ref: '#/components/schemas/SupplyTransactionInteraction'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    SupplyTransactionSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/SupplyTransaction'
      additionalProperties: false

    SupplyTransactionInteraction:
      type: object
      properties:
        startDate:
          format: date-time
          type: string
        request:
          $ref: '#/components/schemas/SupplyOrder'
        response:
          $ref: '#/components/schemas/SupplyOrder'
        endDate:
          format: date-time
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    SupplyTransactionFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        state:
          description: State of this transaction, is a Resource of type [supply-transaction/state](https://hortiapi.com/resource/supply-transaction/state)
          type: string
          default: ''
          x-resource: supply-transaction/state
          externalDocs:
            url: https://hortiapi.com/resource/supply-transaction/state
        supplier:
          $ref: '#/components/schemas/Party'
        customer:
          $ref: '#/components/schemas/Party'
        dateFrom:
          format: date-time
          type: [string, 'null']
        dateTill:
          format: date-time
          type: [string, 'null']
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    Text:
      type: object
      properties:
        value:
          type: string
          example: 'Rosa grootbloemig Red Naomi!'
        language:
          type: string
          example: 'NL'
      additionalProperties: false

    Texts:
      description: Accepts a string (mapped to default language), a single Text object, or an array of Text.
      oneOf:
        - type: string
        - $ref: '#/components/schemas/Text'
        - type: array
          items:
            $ref: '#/components/schemas/Text'
          minItems: 1

    Totals:
      description: Server-computed totals for an order or invoice. Informational only, values supplied by a client are ignored and recalculated by the server.
      type: [object, 'null']
      properties:
        lines:
          type: integer
          description: Number of lines
          example: 12
        pieces:
          format: decimal
          type: number
          description: Total number of pieces over all lines
          example: 480
        net:
          $ref: '#/components/schemas/Amount'
          description: Sum of the lines, excluding VAT and charges
        charges:
          $ref: '#/components/schemas/Amount'
          description: Sum of the charges, excluding VAT
        payable:
          $ref: '#/components/schemas/Amount'
          description: Total amount payable, including VAT
        vat:
          type: array
          description: VAT specification per rate
          items:
            $ref: '#/components/schemas/TotalVat'
      additionalProperties: false

    TotalVat:
      description: VAT amount for a single rate, part of the VAT specification in Totals
      required:
        - rate
        - amount
      type: object
      properties:
        rate:
          $ref: '#/components/schemas/ValueAddedTaxRate'
        percentage:
          type: number
          format: decimal
          description: Percentage value, for example 21 means 21%.
          example: 21
        basis:
          $ref: '#/components/schemas/Amount'
          description: Taxable amount on which the VAT is calculated
        amount:
          $ref: '#/components/schemas/Amount'
          description: VAT amount
      additionalProperties: false

    Unit:
      type: string
      description: UCUM subset (https://ucum.org) for HortiAPI. Use consistent units per type (e.g., cm for dimensions, kg for weight)
      enum:
        #- g      # gram
        - kg     # kilogram
        #- mm     # millimeter
        - cm     # centimeter
        #- m      # meter
        #- mL     # milliliter
        #- L      # liter
        #- cm3    # kubieke centimeter
        #- m3     # kubieke meter
        #- Cel    # graden Celsius
        #- "1"    # unitless (tellen/ratio, indien nodig)

    UnitCode:
      enum:
        - none
        - piece
        - bunch
        - box
        - layer
        - carrier
      type: string
      example: 'box'

    User:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
          example: 'John Doe'
        # role:
        #   type: string
        kind:
          description: Kind of this user, is a Resource of type [user/kind](https://hortiapi.com/resource/user/kind)
          type: string
          default: ''
          x-resource: user/kind
          externalDocs:
            url: https://hortiapi.com/resource/user/kind
        username:
          type: string
          example: 'johndoe@example.com'
        email:
          type: string
          example: 'johndoe@example.com'
        phone:
          type: string
          example: '+31 6 12345678'
        remarks:
          type: string
          example: 'This is a remark'
        companies:
          type: array
          items:
            $ref: '#/components/schemas/UserCompany'
        facilities:
          type: array
          items:
            $ref: '#/components/schemas/UserFacility'
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    UserCompany:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    UserFacility:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        name:
          type: string
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    UserSseEvent:
      type: object
      required: 
        - event
        - data
      properties:
        event:
          $ref: '#/components/schemas/StreamEventType'
        id:
          type: string
          description: SSE event id
        retry:
          type: integer
          minimum: 0
          description: Reconnect delay in ms
        data:
          type: string
          contentMediaType: application/json
          contentSchema:
            $ref: '#/components/schemas/User'
      additionalProperties: false

    UserFilter:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        kind:
          description: Kind of this user, is a Resource of type [user/kind](https://hortiapi.com/resource/user/kind)
          type: string
          default: ''
          x-resource: user/kind
          externalDocs:
            url: https://hortiapi.com/resource/user/kind
        resources:
          $ref: '#/components/schemas/Resources'
      additionalProperties: false

    ValueAddedTaxRate:
      type: string
      enum:
        - unknown
        - standard
        - reduced
        - super-reduced
        - mega-reduced
        - zero
        - exemption
      example: 'standard'
      default: 'standard'



# ProblemDetails / RFC 7807 / ApiError
    HortiApiProblemDetails:
      type: object
      properties:
        type:
          type: string
          format: uri
          description: A URI reference that identifies the problem type. This URI should provide human-readable documentation for the problem type when dereferenced.
        title:
          type: string
          description: A short, human-readable summary of the problem type.
        status:
          type: integer
          format: int32
          description: The HTTP status code generated by the origin server.
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence of the problem.
        instance:
          type: string
          format: uri
          description: A URI reference that identifies the specific occurrence of the problem.
        context:
          type: array
          items:
            $ref: '#/components/schemas/HortiApiProblemDetailsContext'
      required:
        - title
        - status

    HortiApiProblemDetailsContext:
      type: object
      properties:
        name:
          type: string
          description: The name of the context parameter.
        value:
          type: string
          description: The value of the context parameter.


  responses:

    BadRequestError:
      description: Bad request
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/bad-request/no-accept-encoding-header"
            title: "HortiApi request must include a Accept-Encoding header"
            status: 400
            detail: "HortiApi request must include a Accept-Encoding header"
            instance: "/supply"
            context: []

    UnauthorizedError:
      description: Authentication required
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/unauthorized/no-authorization-header"
            title: "Missing authentication header or not starting with Bearer"
            status: 401
            detail: "Missing authentication header or not starting with Bearer"
            instance: "/supply"
            context: []

    ForbiddenError:
      description: Forbidden
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/forbidden"
            title: "Forbidden"
            status: 403
            detail: "You do not have permission to access this resource."
            instance: "/supply"
            context: [
              requiredPermission: "Supply.Read"
            ]

    NotFoundError:
      description: Not Found
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/not-found"
            title: "Resource Not Found"
            status: 404
            detail: "The requested resource was not found."
            instance: "/supply"
            context: [
              resourceType: "Supply",
              resourceId: "12345"
            ]

    ConflictError:
      description: Conflict
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/conflict"
            title: "Conflict"
            status: 409
            detail: "The request could not be completed due to a conflict with the current state of the resource."
            instance: "/stock"
            context: []

    GoneError:
      description: Gone
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/gone"
            title: "Resource is no longer available"
            status: 410
            detail: "The requested resource is no longer available."
            instance: "/stock/search"
            context: []

    InternalServerError:
      description: Internal Server Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/internal-server-error"
            title: "Internal Server Error"
            status: 500
            detail: "An unexpected error occurred on the server."
            instance: "/supply"
            context: [
              errorId: "abcde12345"
            ]

    NotImplemented:
      description: Not Implemented
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/HortiApiProblemDetails'
          example:
            type: "https://hortiapi.com/error/not-implemented"
            title: "Not Implemented"
            status: 501
            detail: "The endpoint '/feature' is not implemented yet."
            instance: "/feature"
            context: [
            ]



  securitySchemes:
    # ApiKeyAuth:
    #   type: apiKey
    #   in: header
    #   name: Authorization
    Bearer:
      type: apiKey
      name: Authorization
      in: header
      description: >-
        Standard Authorization header using the Bearer scheme. Example: "Bearer
        {token}"
      
security:
  - Bearer: []

# Maybe:
#
# Implement usage of application/vnd.hortiapi.v3.0+json
