{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/terminal49/json-schema/terminal49-custom-field-definition-schema.json",
  "title": "Custom field definition",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/terminal49-custom-field-definitions-api-openapi.yml#/components/schemas/custom_field_definition",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "type": "string",
      "enum": [
        "custom_field_definition"
      ]
    },
    "attributes": {
      "type": "object",
      "properties": {
        "entity_type": {
          "type": "string",
          "enum": [
            "Shipment",
            "Container",
            "TrackingRequest"
          ]
        },
        "api_slug": {
          "type": "string"
        },
        "display_name": {
          "type": "string"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "data_type": {
          "type": "string",
          "enum": [
            "short_text",
            "number",
            "date",
            "datetime",
            "boolean",
            "enum",
            "enum_multi",
            "reference"
          ]
        },
        "reference_type": {
          "type": [
            "string",
            "null"
          ]
        },
        "validation": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": true
        },
        "default_format": {
          "type": [
            "string",
            "null"
          ]
        },
        "default_value": {
          "$ref": "#/$defs/custom_field_value"
        }
      },
      "required": [
        "entity_type",
        "api_slug",
        "display_name",
        "data_type"
      ]
    }
  },
  "required": [
    "id",
    "type"
  ],
  "$defs": {
    "custom_field_value": {
      "description": "Raw custom field value (type depends on definition)",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "object"
        }
      ]
    }
  }
}