{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/smartroutes-io/json-schema/smartroutes-io-driver-questionnaire-submission-detail-schema.json",
  "title": "DriverQuestionnaireSubmissionDetail",
  "description": "A driver questionnaire submission with its answers. Returned by `GET /driver-questionnaire-submission/{id}` and, for an order's own submissions, in `driver_questionnaire_submissions` on `GET /orders/{id}`.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/smartroutes-io-openapi.json#/components/schemas/DriverQuestionnaireSubmissionDetail",
  "allOf": [
    {
      "$ref": "#/$defs/DriverQuestionnaireSubmission"
    },
    {
      "type": "object",
      "properties": {
        "route_id": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The route the submission was made on."
        },
        "visit_id": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The stop the submission was made at. `null` for `ROUTE_VEHICLE_CHECKIN` submissions. Matches a stop `id`, but the stop may no longer be planned."
        },
        "driver_questionnaire_answers": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "type": {
                "type": "string",
                "description": "Answer type, e.g. `TEXT`, `CHECKBOX`, `SELECT`, `MULTI_SELECT`, `PHOTO`, `SIGNATURE`. New values may be added; treat unknown values as opaque."
              },
              "data": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The answer as the driver app recorded it. A `MULTI_SELECT` question is answered with one entry per selected option."
              },
              "driver_questionnaire_question": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "question": {
                    "type": "string"
                  }
                }
              },
              "images": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "URLs on `GET /driver-questionnaire-images/{id}` for photos and signatures. Only uploaded images are listed; one still compressing answers `202 Accepted` with a `Retry-After` header."
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "DriverQuestionnaireSubmission": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "order_id": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Set only on `VISIT_ORDER` submissions: the order at the stop this submission is about. `null` for `ROUTE_VEHICLE_CHECKIN` and `VISIT` submissions. Under an order's `stops`, only that order's submissions and the stop's own (`order_id: null`) are listed. An order's own submissions, with their answers, are also in `driver_questionnaire_submissions` on `GET /orders/{id}`."
        },
        "order_line_item_id": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Set only on `VISIT_ORDER` submissions about a single line item of `order_id` — matches `LineItem.id`. `null` when the submission is about the whole order."
        },
        "driver_questionnaire": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "description": "What the questionnaire is attached to. One of `ROUTE_VEHICLE_CHECKIN` (the route), `VISIT` (a stop), or `VISIT_ORDER` (one order, or one line item of an order, at a stop — see `order_id` and `order_line_item_id`). New values may be added; treat unknown values as opaque."
            },
            "title": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}