{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/assignar/json-schema/assignar-order-schema.json",
  "title": "Order",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/assignar-orders-api-openapi.yml#/components/schemas/Order",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "readOnly": true
    },
    "active": {
      "type": "boolean"
    },
    "job_number": {
      "type": "string"
    },
    "po_number": {
      "type": "string"
    },
    "client_id": {
      "type": "integer"
    },
    "order_owner": {
      "type": "integer"
    },
    "project_id": {
      "type": "integer"
    },
    "location": {
      "type": "string"
    },
    "location2": {
      "type": "string"
    },
    "job_description": {
      "type": "string"
    },
    "start_time": {
      "type": "string",
      "description": "The start time of the job in \"HH:MM\" format"
    },
    "shift_duration": {
      "type": "string",
      "description": "The duration of the shift in \"HH:MM\" format"
    },
    "start_date": {
      "type": "string",
      "description": "The start date of the job in \"YYYY-MM-DD\" format"
    },
    "end_date": {
      "type": "string",
      "description": "The end date of the job in \"YYYY-MM-DD\" format"
    },
    "comments": {
      "type": "string"
    },
    "date_created": {
      "type": "string",
      "readOnly": true
    },
    "modified_time": {
      "type": "string",
      "readOnly": true
    },
    "modified_by": {
      "type": "string",
      "readOnly": true
    },
    "status_id": {
      "type": "integer"
    },
    "type_id": {
      "type": "integer"
    },
    "supplier_id": {
      "type": "integer"
    },
    "integration_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "geolocation": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "Point"
          ]
        },
        "coordinates": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    },
    "geolocation2": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "Point"
          ]
        },
        "coordinates": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "tag_id": {
            "type": "integer"
          },
          "tag": {
            "$ref": "#/$defs/Tag"
          }
        }
      }
    },
    "activities": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/OrderActivity"
      }
    }
  },
  "required": [
    "client_id",
    "order_owner",
    "start_date",
    "end_date"
  ],
  "$defs": {
    "OrderActivity": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "activity_id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "external_id": {
          "type": "string"
        },
        "uom_code": {
          "type": "string"
        },
        "quantity": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "activity_id",
        "name",
        "external_id",
        "uom_code"
      ]
    },
    "Tag": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "readOnly": true
        },
        "taxonomy": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "color": {
          "type": "string"
        },
        "integration_id": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 255,
          "description": "Nullable varchar(255) with uniqueness constraint. Used for external system integration identifiers."
        }
      },
      "required": [
        "taxonomy",
        "name"
      ]
    }
  }
}