{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/valjeanspecialty/json-schema/valjeanspecialty-answer-result-schema.json",
  "title": "AnswerResult",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/valjeanspecialty-openapi.yaml#/components/schemas/AnswerResult",
  "type": "object",
  "properties": {
    "answered": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Keys that were recorded."
    },
    "unmatched": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Keys not asked on this file (still saved in the file note)."
    },
    "rejected": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "reason"
        ]
      },
      "description": "Answers that didn't fit the expected type: not saved."
    },
    "upload_instead": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Keys that need a document upload rather than text."
    },
    "fields_filled": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Fields that were blank and are now filled."
    },
    "fields_kept": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Fields Valjean already had: kept, not overwritten."
    },
    "from_message": {
      "type": "object",
      "properties": {
        "answers": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string"
              },
              "value": {
                "type": "string"
              }
            },
            "required": [
              "key",
              "value"
            ]
          },
          "description": "Answers read from message (keys you also sent directly are left to yours)."
        },
        "fields": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Fields read from message."
        },
        "not_understood": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Sentences or values that couldn't be mapped. Send them by key, or reword."
        }
      },
      "required": [
        "answers",
        "fields",
        "not_understood"
      ],
      "description": "Only when message was sent: what Valjean understood from it."
    },
    "note": {
      "type": "string"
    },
    "needs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Need"
      },
      "description": "What's still open after these answers."
    }
  },
  "required": [
    "answered",
    "unmatched",
    "rejected",
    "upload_instead",
    "fields_filled",
    "fields_kept",
    "note",
    "needs"
  ],
  "$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"
      ]
    },
    "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"
      ]
    }
  }
}