{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/valjeanspecialty/json-schema/valjeanspecialty-submission-schema.json",
  "title": "Submission",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/valjeanspecialty-openapi.yaml#/components/schemas/Submission",
  "allOf": [
    {
      "$ref": "#/$defs/SubmissionSummary"
    },
    {
      "type": "object",
      "properties": {
        "files": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "File names on the submission."
        },
        "needs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Need"
          },
          "description": "What's still open, each with a key. Empty once the file is closed."
        },
        "quotes_ready": {
          "type": "integer",
          "description": "Quotes your broker has presented."
        },
        "markets": {
          "$ref": "#/$defs/MarketProgress"
        },
        "broker": {
          "anyOf": [
            {
              "$ref": "#/$defs/Broker"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "files",
        "needs",
        "quotes_ready",
        "markets",
        "broker"
      ]
    }
  ],
  "$defs": {
    "AnswerSpec": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "How to answer. \"file\" means upload a document instead.",
          "enum": [
            "text",
            "number",
            "money",
            "percent",
            "yes_no",
            "choice",
            "date",
            "file"
          ]
        },
        "options": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "For type \"choice\": the allowed answers."
        }
      },
      "required": [
        "type"
      ]
    },
    "Broker": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": "string",
          "format": "email"
        }
      },
      "required": [
        "name",
        "email"
      ]
    },
    "MarketProgress": {
      "type": "object",
      "properties": {
        "reviewing": {
          "type": "integer"
        },
        "declined": {
          "type": "integer"
        },
        "quoted": {
          "type": "integer"
        },
        "no_response": {
          "type": "integer"
        },
        "total": {
          "type": "integer",
          "description": "Markets the file has been sent to."
        },
        "presented": {
          "type": "integer",
          "description": "Quotes your broker has presented to you."
        },
        "text": {
          "type": "string",
          "description": "One plain sentence, e.g. \"With 4 markets: 3 quoted, 1 declined.\""
        }
      },
      "required": [
        "reviewing",
        "declined",
        "quoted",
        "no_response",
        "total",
        "presented",
        "text"
      ],
      "description": "Anonymous counts: market names appear only on presented quotes."
    },
    "Need": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "description": "document, field, question, photo, or \"requested\" (an item your broker asked for)."
        },
        "level": {
          "type": "string",
          "enum": [
            "required",
            "recommended"
          ]
        },
        "how": {
          "type": "string",
          "description": "\"answer\", \"upload a document\" or \"answer or upload\"."
        },
        "answer": {
          "$ref": "#/$defs/AnswerSpec"
        }
      },
      "required": [
        "key",
        "label",
        "type",
        "level",
        "how",
        "answer"
      ]
    },
    "SubmissionSummary": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "reference": {
          "type": "string",
          "description": "Valjean reference, e.g. VS-000624."
        },
        "insured": {
          "type": "string"
        },
        "lines": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Line names, e.g. \"General Liability\"."
        },
        "effective_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "status": {
          "type": "string",
          "description": "Plain-English status you can show as is."
        },
        "stage": {
          "type": "string",
          "enum": [
            "new",
            "needs_info",
            "marketing",
            "quoted",
            "bound",
            "declined",
            "lost",
            "closed"
          ]
        },
        "received_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "reference",
        "insured",
        "lines",
        "effective_date",
        "status",
        "stage",
        "received_at",
        "updated_at"
      ]
    }
  }
}