{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/terminal49/json-schema/terminal49-custom-field-schema.json",
  "title": "Custom field",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/terminal49-custom-fields-api-openapi.yml#/components/schemas/custom_field",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "type": "string",
      "enum": [
        "custom_field"
      ]
    },
    "attributes": {
      "type": "object",
      "properties": {
        "api_slug": {
          "type": "string"
        },
        "value": {
          "$ref": "#/$defs/custom_field_value"
        },
        "display_value": {
          "type": [
            "string",
            "null"
          ],
          "description": "Formatted value for display"
        }
      },
      "required": [
        "api_slug"
      ]
    },
    "relationships": {
      "type": "object",
      "properties": {
        "entity": {
          "type": "object",
          "properties": {
            "data": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "shipment",
                    "container",
                    "tracking_request"
                  ]
                },
                "id": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "required": [
                "type",
                "id"
              ]
            }
          }
        },
        "definition": {
          "type": "object",
          "properties": {
            "data": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "custom_field_definition"
                  ]
                },
                "id": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "required": [
                "type",
                "id"
              ]
            }
          }
        }
      }
    }
  },
  "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"
        }
      ]
    }
  }
}