# Copyright 2021 - 2025 PeopleWare n.v.
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

type: object
examples:
  - structureVersion: 1
    results:
      - structureVersion: 1
        discriminator: companies/company
        href: /companies/v1/company/5646897945?at=2021-01-19T17:14:18.482Z
        crn: '5646897945'
        name:
          nl: Het Bedrijf
          fr: La Compagnie
      - structureVersion: 2
        discriminator: persons/person
        href: /persons/v1/person/6908390?at=2021-01-19T17:14:18.482Z
        inss: '96110505648'
        firstName: Anna
        lastName: Van Deuren
    href:
      first: search?searchTerm=find%20me&page=1&per_page=27
      previous: search?searchTerm=find%20me&page=3&per_page=27
      next: search?searchTerm=find%20me&page=5&per_page=27
      last: search?searchTerm=find%20me&page=22&per_page=27
  - structureVersion: 1
    results: []
    href:
      first: search?searchTerm=find%20me&page=1&per_page=27
      last: search?searchTerm=find%20me&page=1&per_page=27
properties:
  structureVersion:
    type: integer
    examples:
      - 1
    description: Version of the data structure of this resource type
    minimum: 1
  results:
    type: array
    examples:
      - - structureVersion: 1
          discriminator: companies/company
          href: /companies/v1/company/5646897945?at=2021-01-19T17:14:18.482Z
          crn: '5646897945'
          name:
            nl: Het Bedrijf
            fr: La Compagnie
        - structureVersion: 2
          discriminator: persons/person
          href: /persons/v1/person/6908390?at=2021-01-19T17:14:18.482Z
          inss: '96110505648'
          firstName: Anna
          lastName: Van Deuren
      - []
    description: >-
      List of items that match the search, ordered by relevance. The list has `per_page` or fewer items.


      Items identify the type of resource they represent (`discriminator`), a link to the indexed version of the found
      resource (`href`), and information for humans to recognize the found resource. The entries can have different
      `structureVersions`, even for the same `discriminator`. The precise structure of each entry, beyond the base
      properties, is a contract between the service in which the resource resides and clients of the search service.
      This is opaque to the search service, which acts as intermediate.


      The list has the requested number of items, except for the first and last page. The `href.first` page can be
      empty, or have fewer elements than `per_page`. The `href.last` page can have fewer reference in the response than
      `per_page`, but cannot be empty. Other pages have exactly the `per_page` as number of items.
    maxItems: 100
    uniqueItems: true
    items:
      type: object
      examples:
        - structureVersion: 2
          discriminator: my-service/some-resource
          href: /my-service/v6/some-resource/564845?at=2021-01-19T17:14:18.482558Z
      description: >-
        The resource's search document with the most up-to-date information, i.e., up-to-date up until, but not
        including, `x-date`.


        This is a contract between this service and clients of the search service. Specific properties are added for
        different `discriminators`. When returned by the search service, the property `href` is added. This is the
        canonical URI of the found resource, including an `at` query parameter, that refers to the precise version of
        the found resource that was indexed.
      properties:
        discriminator:
          type: string
          examples:
            - my-service/some-resource
          description: >-
            Type of the indexed resource.


            This enables users to search only on particular resource type. The type is qualified with the service name,
            to avoid name clashes (slash-separated).
          minLength: 1
          pattern: ^([-a-z0-9]+)\/([-a-z0-9/]+)$
        href:
          type: string
          examples:
            - /my-service/v1/y/abc?at=2020-01-23T15:22:39.254888Z
          description: >-
            Canonical URI where the found resource's information is located, at the version that was indexed (`at`
            parameter _must_ be included).


            Users need to be directed to the version returned by the search index, and not an earlier or more recent
            version. The search engine updates, eventually, after a few seconds. If a more recent version is available
            in the meantime, the user interface makes it possible for the user to navigate to that version.


            A _canonical URI_ is the URI where are resource can be interacted with, without the scheme and authority
            (see [RFC 3986 Uniform Resource Identifier (URI): Generic Syntax; 3. Syntax
            Components](https://www.rfc-editor.org/rfc/rfc3986#section-3)), and without the build number. By convention,
            the canonical URI’s first segment is the name of the service in which the URI resides, followed by the
            relative URI of the resource in the API of that service.


            The URI has an `at` qyuery parameter, expressing the knowledge time for which the service should return the
            resource. The value must be a moment in time, expressed as ISO-8601 in UTC ('Z'), to ms precision or more
            precise (should be μs precision).
          format: uri-reference
          minLength: 1
        structureVersion:
          type: integer
          examples:
            - 2
          description: Version of the data structure of this resource type
          minimum: 1
      required:
        - discriminator
        - href
        - structureVersion
      additionalProperties: true
  href:
    type: object
    examples:
      - first: search?searchTerm=find%20me&page=1&per_page=27
        previous: search?searchTerm=find%20me&page=3&per_page=27
        next: search?searchTerm=find%20me&page=5&per_page=27
        last: search?searchTerm=find%20me&page=22&per_page=27
    description: Links to other pages of the search result.
    properties:
      first:
        type: string
        examples:
          - search?searchTerm=find%20me&page=1&per_page=27
        description: >-
          Relative uri of the first page, with the same `per_page`, of the search this is a result of.


          This page can be empty. It might contain fewer items than requested by `per_page`, but then this value is
          equal to `last`.
        format: uri-reference
        minLength: 1
      previous:
        type: string
        examples:
          - search?searchTerm=find%20me&page=3&per_page=27
        description: >-
          Relative uri of the previous page, with the same `per_page`, of the search this is a result of, if this is not
          the `first` page.


          If this is the `first` page, this property does not appear.


          This page can never be empty. It might contain fewer items than requested by `per_page`, but then this value
          is equal to `first`.
        format: uri-reference
        minLength: 1
      next:
        type: string
        examples:
          - search?searchTerm=find%20me&page=5&per_page=27
        description: >-
          Relative uri of the next page, with the same `per_page`, of the search this is a result of, if there is a next
          page.


          If this is the `last` page, this property does not appear.


          This page can never be empty. It might contain fewer items than requested by `per_page`, but then this value
          is equal to `last`.
        format: uri-reference
        minLength: 1
      last:
        type: string
        examples:
          - search?searchTerm=find%20me&page=22&per_page=27
        description: >-
          Relative uri of the last page, with the same `per_page`, of the search this is a result of.


          The page can never be empty, but it might contain fewer items than requested by `per_page`.
        format: uri-reference
        minLength: 1
    required:
      - first
      - last
    additionalProperties: true
required:
  - structureVersion
  - results
  - href
additionalProperties: true
