{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "document.schema.json",
    "title": "Document",
    "type": "object",
    "description": "Общие свойства документов",
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid"
        },
        "number": {
            "type": "string",
            "description": "Номер документа"
        },
        "date": {
            "type": "string",
            "format": "date",
            "description": "Дата документа"
        },
        "type": {
            "enum": [
                "CONTRACT",
                "ORDER",
                "ADDITIONAL_AGREEMENT",
                "COMPLAINT"
            ],
            "description": "Тип документа"
        },
        "direction": {
            "enum": [
                "EXPORT",
                "IMPORT"
            ],
            "description": "Тип документа \n\n - `EXPORT`: экспортный \n - `IMPORT`: импортный"
        },
        "customer": {
            "$ref": "customer.schema.json",
            "description": "Заказчик"
        },
        "agent": {
            "$ref": "agent.schema.json",
            "description": "Агент"
        },
        "canceledBy": {
            "$ref": "user.schema.json",
            "description": "Пользователь отменивший документ"
        },
        "notApprovalComment": {
            "type": "string",
            "description": "Комментарий при не согласовании документа"
        },
        "userEmployee": {
            "$ref": "user.schema.json",
            "description": "Пользователь исполнителя"
        },
        "userCustomer": {
            "$ref": "user.schema.json",
            "description": "Последний пользователь клиента изменивший документ"
        },
        "createdAt": {
            "description": "Дата и время создания документа",
            "type": "string",
            "format": "datetime"
        },
        "changedAt": {
            "description": "Дата и время последнего изменения документа",
            "type": "string",
            "format": "datetime"
        },
        "notValidAfter": {
            "description": "Не действительно после",
            "type": "string",
            "format": "date"
        },
        "files": {
            "type": "array",
            "items": {
                "title": "File",
                "$ref": "file.schema.json"
            },
            "uniqueItems": true
        }
    },
    "additionalProperties": false,
    "required": [
        "id",
        "type",
        "customer"
    ]
}