{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/smartroutes-io/json-schema/smartroutes-io-plan-optimisation-response-schema.json",
  "title": "PlanOptimisationResponse",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/smartroutes-io-openapi.json#/components/schemas/PlanOptimisationResponse",
  "type": "object",
  "required": [
    "optimisation",
    "plan"
  ],
  "properties": {
    "optimisation": {
      "type": "object",
      "required": [
        "id",
        "in_progress"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "in_progress": {
          "type": "boolean"
        }
      }
    },
    "plan": {
      "type": "object",
      "required": [
        "id",
        "dispatched"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "dispatched": {
          "type": "boolean"
        }
      }
    },
    "errors": {
      "type": "array",
      "description": "Orders left out of the optimisation, each with the reason. May be absent.",
      "items": {
        "type": "object",
        "required": [
          "name",
          "description",
          "details"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Reason code (e.g. `IN_ANOTHER_PLAN`)."
          },
          "description": {
            "type": "string",
            "description": "Human-readable explanation."
          },
          "details": {
            "type": "object",
            "required": [
              "id",
              "order_number"
            ],
            "properties": {
              "id": {
                "type": "integer",
                "description": "Order id."
              },
              "order_number": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Order number."
              },
              "plan_ids": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "description": "Plans the order already belongs to."
              }
            }
          }
        }
      }
    }
  }
}