{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hedgespecialty-com/json-schema/hedgespecialty-com-shared-question-schema.json",
  "title": "SharedQuestion",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hedgespecialty-com-openapi.yml#/components/schemas/SharedQuestion",
  "type": "object",
  "required": [
    "id",
    "key",
    "label",
    "help",
    "type",
    "options",
    "required",
    "show_if",
    "section",
    "assumed_default",
    "prefill_from"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "The program's own answer path, stable within the set (an object's parts are `<object>.<part>`)."
    },
    "key": {
      "type": "string",
      "description": "Shared answer key: Hedge's fact key when the question means that fact in the same form, else `program.<program_slug>.<id>`."
    },
    "label": {
      "type": "string"
    },
    "help": {
      "type": [
        "string",
        "null"
      ]
    },
    "type": {
      "type": "string",
      "enum": [
        "text",
        "textarea",
        "number",
        "currency",
        "percent",
        "integer",
        "boolean",
        "select",
        "multiselect",
        "date",
        "state",
        "address",
        "list"
      ],
      "description": "`list`: the answer is a JSON array; rows shaped by `item_questions`, or plain text values when `item_questions` is absent."
    },
    "options": {
      "type": "array",
      "description": "Choices for select / multiselect (empty otherwise). Send `value` unchanged; it may be a string, number or boolean.",
      "items": {
        "type": "object",
        "required": [
          "value",
          "label"
        ],
        "properties": {
          "value": {},
          "label": {
            "type": "string"
          }
        }
      }
    },
    "required": {
      "type": "boolean",
      "description": "Required whenever the question is shown."
    },
    "show_if": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SharedQuestionCondition"
      }
    },
    "required_if": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SharedQuestionCondition"
      },
      "description": "When present, the question is required only while these conditions hold."
    },
    "one_of_group": {
      "type": "string",
      "description": "An answer to any question in the same group satisfies the group."
    },
    "section": {
      "type": [
        "string",
        "null"
      ]
    },
    "assumed_default": {
      "nullable": true,
      "description": "The answer Hedge would assume when unanswered, when one is fixed in advance; null otherwise (Hedge then decides from the file at quote time)."
    },
    "prefill_from": {
      "type": [
        "string",
        "null"
      ]
    },
    "item_questions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SharedQuestion"
      },
      "description": "For a `list`: each row's questions. Keys are `<list key>.<id>`; a row condition on a sibling uses the sibling's key."
    }
  },
  "$defs": {
    "SharedQuestion": {
      "type": "object",
      "required": [
        "id",
        "key",
        "label",
        "help",
        "type",
        "options",
        "required",
        "show_if",
        "section",
        "assumed_default",
        "prefill_from"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "The program's own answer path, stable within the set (an object's parts are `<object>.<part>`)."
        },
        "key": {
          "type": "string",
          "description": "Shared answer key: Hedge's fact key when the question means that fact in the same form, else `program.<program_slug>.<id>`."
        },
        "label": {
          "type": "string"
        },
        "help": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string",
          "enum": [
            "text",
            "textarea",
            "number",
            "currency",
            "percent",
            "integer",
            "boolean",
            "select",
            "multiselect",
            "date",
            "state",
            "address",
            "list"
          ],
          "description": "`list`: the answer is a JSON array; rows shaped by `item_questions`, or plain text values when `item_questions` is absent."
        },
        "options": {
          "type": "array",
          "description": "Choices for select / multiselect (empty otherwise). Send `value` unchanged; it may be a string, number or boolean.",
          "items": {
            "type": "object",
            "required": [
              "value",
              "label"
            ],
            "properties": {
              "value": {},
              "label": {
                "type": "string"
              }
            }
          }
        },
        "required": {
          "type": "boolean",
          "description": "Required whenever the question is shown."
        },
        "show_if": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SharedQuestionCondition"
          }
        },
        "required_if": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SharedQuestionCondition"
          },
          "description": "When present, the question is required only while these conditions hold."
        },
        "one_of_group": {
          "type": "string",
          "description": "An answer to any question in the same group satisfies the group."
        },
        "section": {
          "type": [
            "string",
            "null"
          ]
        },
        "assumed_default": {
          "nullable": true,
          "description": "The answer Hedge would assume when unanswered, when one is fixed in advance; null otherwise (Hedge then decides from the file at quote time)."
        },
        "prefill_from": {
          "type": [
            "string",
            "null"
          ]
        },
        "item_questions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SharedQuestion"
          },
          "description": "For a `list`: each row's questions. Keys are `<list key>.<id>`; a row condition on a sibling uses the sibling's key."
        }
      }
    },
    "SharedQuestionCondition": {
      "type": "object",
      "required": [
        "key",
        "op",
        "value"
      ],
      "description": "One condition on another question's answer, found by that\nquestion's `key`. Conditions in a list are ANDed. Semantics: `eq`\nand `in` compare type and value exactly; `ne` / `not_in` are false\nfor an unanswered question; `truthy` is true unless the answer is\nnull, false, 0, \"\" or an empty list or object; `falsy` is exactly\nfalse, 0 or \"\" (an unanswered question is not falsy); `gt` /\n`gte` / `lt` / `lte` compare numbers; `exists` is whether the\nquestion is answered. `any_of` / `all_of` group `conditions` (then\n`key` is null). `any_item`: the answer is a list and one item must\nsatisfy `op` / `value`. A condition whose `key` no question carries\nrefers to a fact Hedge sets itself; treat it as unanswered.\n",
      "properties": {
        "key": {
          "type": [
            "string",
            "null"
          ]
        },
        "op": {
          "type": "string",
          "enum": [
            "eq",
            "ne",
            "in",
            "not_in",
            "truthy",
            "falsy",
            "gt",
            "gte",
            "lt",
            "lte",
            "exists",
            "any_of",
            "all_of"
          ]
        },
        "value": {
          "description": "Comparison value (JSON)",
          "null for truthy / falsy / groups.": null
        },
        "any_item": {
          "type": "boolean"
        },
        "reference": {
          "type": "object",
          "description": "A keyed-row lookup Hedge evaluates natively."
        },
        "conditions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SharedQuestionCondition"
          }
        }
      }
    }
  }
}