{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hmcts/json-schema/hmcts-result-code-get-detail-dto-schema.json",
  "title": "result-code-get-detail-dto",
  "description": "Immutable DTO representing a detailed Result Code.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hmcts-result-codes-api-openapi.yml#/components/schemas/result-code-get-detail-dto",
  "properties": {
    "resultCode": {
      "description": "Code that identifies the result.",
      "type": "string"
    },
    "title": {
      "description": "Human-readable title.",
      "type": "string"
    },
    "wording": {
      "$ref": "#/$defs/template-detail"
    },
    "startDate": {
      "description": "Date the Result Code became active.",
      "format": "date",
      "type": "string"
    },
    "endDate": {
      "description": "Date the Result Code became inactive. `null` indicates that this row is still active.",
      "format": "date",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "endDate",
    "resultCode",
    "startDate",
    "title",
    "wording"
  ],
  "type": "object",
  "$defs": {
    "template-constraint": {
      "description": "The template field with an associated value",
      "properties": {
        "type": {
          "description": "The data type of the value.",
          "enum": [
            "TEXT"
          ],
          "type": "string"
        },
        "length": {
          "description": "The length of the data value.",
          "type": "integer"
        }
      },
      "required": [
        "length",
        "type"
      ],
      "type": "object"
    },
    "template-detail": {
      "description": "The wording details",
      "properties": {
        "template": {
          "description": "The template name. It contains the field names between curly braces.",
          "type": "string"
        },
        "substitution-key-constraints": {
          "description": "A list of fields and the associated constraints",
          "items": {
            "$ref": "#/$defs/template-key-with-constraint"
          },
          "type": "array"
        }
      },
      "required": [
        "template"
      ],
      "type": "object"
    },
    "template-key-with-constraint": {
      "description": "The template field with an associated value",
      "properties": {
        "key": {
          "description": "Field key for substitution into the template.",
          "type": "string"
        },
        "value": {
          "description": "The optional value for the key.",
          "type": "string"
        },
        "constraint": {
          "allOf": [
            {
              "$ref": "#/$defs/template-constraint"
            }
          ],
          "description": "The constraint details for the field"
        }
      },
      "required": [
        "constraint",
        "key"
      ],
      "type": "object"
    }
  }
}