# For syntax see: https://json-schema.org/understanding-json-schema
$schema: "https://json-schema.org/draft/2020-12/schema"
description: PEtab 2.0 parameter estimation problem configuration schema.

definitions:
  list_of_files:
    type: array
    description: List of files.
    items:
      type: string
      description: |
        File name or URL, absolute or relative to the location of the PEtab
        problem configuration file.
  version_number:
    type: string
    pattern: ^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$
    description: Version number.

properties:

  format_version:
    anyOf:
      - $ref: "#/definitions/version_number"
      - type: integer
    description: Version of the PEtab format.

  id:
    type: string
    description: |
      Identifier of the PEtab problem.

      This is optional and has no effect on the PEtab problem itself.
    pattern: "^[a-zA-Z_]\\w*$"

  parameter_files:
    description: List of PEtab parameter files.
    $ref: "#/definitions/list_of_files"

  model_files:
    type: object
    description: One or multiple models.

    # the model ID
    patternProperties:
      "^[a-zA-Z_]\\w*$":
        type: object
        properties:
          location:
            type: string
            description: |
              Model file name or URL, absolute or relative to the location of
              the PEtab problem configuration file.
          language:
            type: string
            description: |
              Model language, e.g., 'sbml', 'cellml', 'bngl', 'pysb'
        required:
          - location
          - language
    additionalProperties: false

  measurement_files:
    description: List of PEtab measurement files.
    $ref: "#/definitions/list_of_files"

  condition_files:
    description: List of PEtab condition files.
    $ref: "#/definitions/list_of_files"

  experiment_files:
    description: List of PEtab experiment files.
    $ref: "#/definitions/list_of_files"

  observable_files:
    description: List of PEtab observable files.
    $ref: "#/definitions/list_of_files"

  mapping_files:
    description: List of PEtab mapping files.
    $ref: "#/definitions/list_of_files"

  extensions:
    type: object
    description: |
      PEtab extensions being used.
    patternProperties:
      "^[a-zA-Z][\\-\\w]*$":

        type: object
        description: |
          Information on a specific extension
        properties:
          version:
            $ref: "#/definitions/version_number"
          required:
            type: boolean
            description: |
              Indicates whether the extension is required for the
              mathematical interpretation of the problem.
        required:
          - version
          - required
      additionalProperties: true

    additionalProperties: false

required:
  - format_version
  - parameter_files
  - model_files
  - observable_files
  - measurement_files

additionalProperties: false
