{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "https://raw.githubusercontent.com/NovoNordisk-OpenSource/mighty.metadata/refs/heads/main/inst/schema/mighty.json",
  "title": "Mighty Configuration",
  "description": "Schema for mighty framework configuration in the mightyverse",
  "type": "object",
  "properties": {
    "external_data": {
      "description": "External data sources referenced by the study",
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "#/definitions/external_data_source"
      }
    }
  },
  "required": ["external_data"],
  "additionalProperties": false,
  "definitions": {
    "external_data_source": {
      "description": "Specification of a single external data source",
      "type": "object",
      "properties": {
        "id": {
          "description": "Identifier of the external data source",
          "$ref": "#/definitions/cdisc/name"
        },
        "keys": {
          "description": "Key columns for joining the external data",
          "$ref": "#/definitions/keys"
        }
      },
      "required": ["id", "keys"],
      "additionalProperties": false
    },
    "keys": {
      "description": "Keys are always unique and of minimum length 1",
      "oneOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/cdisc/name"
          },
          "minItems": 1,
          "uniqueItems": true
        },
        {
          "$ref": "#/definitions/cdisc/name"
        }
      ]
    },
    "cdisc": {
      "description": "Definitions from CDISC standards",
      "name": {
        "description": "Uppercase identifier",
        "type": "string",
        "pattern": "^[A-Z][A-Z0-9_]*$"
      }
    }
  }
}
