{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hmcts/json-schema/hmcts-case-type-schema.json",
  "title": "CaseType",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hmcts-data-api-openapi.yml#/components/schemas/CaseType",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique identifier for a Case Type."
    },
    "version": {
      "$ref": "#/$defs/Version"
    },
    "name": {
      "type": "string",
      "description": "Display name of the Case Type."
    },
    "jurisdiction": {
      "$ref": "#/$defs/Jurisdiction"
    },
    "events": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CaseEvents"
      }
    },
    "states": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CaseState"
      }
    },
    "case_fields": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CaseField"
      }
    }
  },
  "required": [
    "id",
    "version",
    "name",
    "Jurisdiction",
    "states"
  ],
  "$defs": {
    "CaseEventField": {
      "type": "object",
      "properties": {
        "case_field_id": {
          "type": "string",
          "description": "Foriegn key to CaseField.id"
        },
        "required": {
          "type": "boolean",
          "description": "whether this field is required for this event or not"
        }
      },
      "required": [
        "case_field_id",
        "required"
      ]
    },
    "CaseEvents": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "case_fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CaseEventField"
          }
        },
        "valid_pre_states": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "post_state": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "CaseField": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The id of the case field"
        },
        "case_type_id": {
          "type": "string",
          "description": "Foriegn key to the case type as fields should not work across"
        },
        "label": {
          "type": "string"
        },
        "hint_text": {
          "type": "string"
        },
        "field_type": {
          "$ref": "#/$defs/FieldType"
        },
        "hidden": {
          "type": "boolean"
        },
        "validation_expr": {
          "type": "string"
        },
        "security_label": {
          "type": "string",
          "description": "Gov security level of the data (official, top secret etc)"
        },
        "live_from": {
          "type": "string"
        },
        "live_until": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "label",
        "field_type"
      ]
    },
    "CaseState": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "description": "Short name to display.",
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      },
      "required": [
        "id"
      ]
    },
    "FieldType": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        }
      }
    },
    "Jurisdiction": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "live_from": {
          "type": "string",
          "format": "date-time"
        },
        "live_until": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "Version": {
      "type": "object",
      "properties": {
        "number": {
          "type": "integer",
          "description": "Sequantial version number"
        },
        "live_from": {
          "type": "string",
          "format": "date-time",
          "description": "Date and time from when this version is valid from"
        },
        "live_until": {
          "type": "string",
          "format": "date-time",
          "description": "Date and time this version is to be retired"
        }
      },
      "required": [
        "number",
        "live_from"
      ]
    }
  }
}