{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/assignar/json-schema/assignar-order-template-schema.json",
  "title": "OrderTemplate",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/assignar-order-templates-api-openapi.yml#/components/schemas/OrderTemplate",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "readOnly": true
    },
    "name": {
      "type": "string"
    },
    "order_comment": {
      "type": [
        "string",
        "null"
      ]
    },
    "order_duration": {
      "type": "integer",
      "description": "Template duration in days"
    },
    "created_by": {
      "type": [
        "integer",
        "null"
      ],
      "readOnly": true
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "modified_by": {
      "type": [
        "integer",
        "null"
      ],
      "readOnly": true
    },
    "modified_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "readOnly": true
    },
    "deleted_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "readOnly": true,
      "description": "Soft-delete timestamp; null for active templates"
    },
    "deleted_by_id": {
      "type": [
        "integer",
        "null"
      ],
      "readOnly": true,
      "description": "User id who soft-deleted the template; null for active templates"
    },
    "tasks": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/OrderTemplateTask"
      }
    },
    "activities": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/OrderTemplateActivity"
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/OrderTemplateTag"
      }
    }
  },
  "$defs": {
    "OrderTemplateActivity": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "activity_id": {
          "type": "integer"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "external_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "uom_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "deleted_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Soft-delete timestamp on the underlying activity; null when the activity is not deleted"
        },
        "deleted_by_id": {
          "type": [
            "integer",
            "null"
          ],
          "description": "User id who soft-deleted the underlying activity; null when the activity is not deleted"
        },
        "integration_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "External system identifier for the underlying activity"
        }
      }
    },
    "OrderTemplateTag": {
      "type": "object",
      "properties": {
        "tag_id": {
          "type": "integer",
          "description": "Identifier of the tag"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "color": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "OrderTemplateTask": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "task_id": {
          "type": "integer"
        },
        "task_description": {
          "type": "string"
        },
        "task_quantity": {
          "type": "integer"
        },
        "task_start_time": {
          "type": "string",
          "description": "Shift start time in \"HH:MM\" (24-hour) format",
          "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
        },
        "task_end_time": {
          "type": "string",
          "description": "Shift end time in \"HH:MM\" (24-hour) format",
          "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
        },
        "task_offset": {
          "type": "integer",
          "description": "Days after the order start date this task begins"
        },
        "task_duration": {
          "type": "integer",
          "description": "Task duration in days"
        },
        "task": {
          "type": [
            "object",
            "null"
          ],
          "description": "The underlying task this template line references",
          "properties": {
            "id": {
              "type": "integer"
            },
            "name": {
              "type": "string"
            },
            "external_id": {
              "type": [
                "string",
                "null"
              ]
            },
            "active": {
              "type": "boolean"
            },
            "deleted_at": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "Soft-delete timestamp on the underlying task; null when the task is not deleted"
            },
            "deleted_by_id": {
              "type": [
                "integer",
                "null"
              ],
              "description": "User id who soft-deleted the underlying task; null when the task is not deleted"
            },
            "integration_id": {
              "type": [
                "string",
                "null"
              ],
              "description": "External system identifier for the underlying task"
            }
          }
        },
        "forms": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/OrderTemplateTaskForm"
          }
        }
      }
    },
    "OrderTemplateTaskForm": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "form_id": {
          "type": "integer"
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "active": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether the underlying form is active; null if the form no longer resolves"
        },
        "archived": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether the underlying form is archived; null if the form no longer resolves"
        }
      }
    }
  }
}