{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/loopgantt-com/json-schema/loopgantt-com-create-gantt-request-schema.json",
  "title": "CreateGanttRequest",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/loopgantt-com-openapi.json#/components/schemas/CreateGanttRequest",
  "type": "object",
  "required": [
    "name",
    "tasks"
  ],
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 200,
      "description": "Project name"
    },
    "description": {
      "type": "string",
      "maxLength": 2000
    },
    "startDate": {
      "type": "string",
      "format": "date",
      "description": "Project start (YYYY-MM-DD). Defaults to today."
    },
    "deadline": {
      "type": "string",
      "format": "date",
      "description": "Optional deadline (YYYY-MM-DD, on or after startDate). Drawn as a deadline line on the chart; compare with schedule.projectEndDate to check the plan fits."
    },
    "workDays": {
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 1,
        "maximum": 7
      },
      "description": "Working weekdays as ISO numbers (1 = Monday … 7 = Sunday). Defaults to Mon–Fri."
    },
    "holidays": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "string",
        "format": "date"
      },
      "description": "Non-working dates (YYYY-MM-DD)"
    },
    "tasks": {
      "type": "array",
      "minItems": 1,
      "maxItems": 300,
      "items": {
        "$ref": "#/$defs/GanttTaskInput"
      },
      "description": "Tasks in execution order. Durations + lags may add up to at most 5000 days."
    }
  },
  "$defs": {
    "DependencyInput": {
      "type": "object",
      "required": [
        "task"
      ],
      "properties": {
        "task": {
          "type": "integer",
          "minimum": 0,
          "description": "Index (0-based) of an EARLIER task this task depends on"
        },
        "type": {
          "type": "string",
          "enum": [
            "FS",
            "SS",
            "FF",
            "SF"
          ],
          "default": "FS",
          "description": "Dependency type: finish-to-start (default), start-to-start, finish-to-finish, start-to-finish"
        },
        "lag": {
          "type": "integer",
          "minimum": -365,
          "maximum": 365,
          "default": 0,
          "description": "Lag (positive) or lead (negative) in working days"
        }
      }
    },
    "GanttTaskInput": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 200,
          "description": "Task name"
        },
        "duration": {
          "type": "integer",
          "minimum": 0,
          "maximum": 3650,
          "default": 1,
          "description": "Duration in working days. 0 makes the task a milestone."
        },
        "isMilestone": {
          "type": "boolean",
          "default": false,
          "description": "Milestone (zero duration, drawn as a diamond)"
        },
        "description": {
          "type": "string",
          "maxLength": 2000
        },
        "dependencies": {
          "type": "array",
          "maxItems": 20,
          "description": "Predecessors: plain task indices (0-based, earlier tasks only) or objects with type/lag",
          "items": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": 0
              },
              {
                "$ref": "#/$defs/DependencyInput"
              }
            ]
          }
        },
        "isPhase": {
          "type": "boolean",
          "default": false,
          "description": "Top-level phase (a group). Tasks join it via parent = this task's position. Phases take no dependencies and no parent; their dates are the envelope of their tasks."
        },
        "parent": {
          "type": "integer",
          "minimum": 0,
          "description": "Position (0-based) of an EARLIER task with isPhase=true that this task belongs to."
        },
        "deadline": {
          "type": "string",
          "format": "date",
          "description": "Finish-by date (YYYY-MM-DD). A marker, not a constraint: the task is scheduled normally and the response reports its fit (buffer or days late)."
        }
      }
    }
  }
}