{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mdflow-cz/json-schema/mdflow-cz-document-schema.json",
  "title": "Document",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mdflow-cz-openapi.json#/components/schemas/Document",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "title",
    "folder_id",
    "is_public",
    "workspace_id",
    "path",
    "path_string",
    "body",
    "compounded_description",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "title": {
      "type": "string"
    },
    "folder_id": {
      "type": "string",
      "format": "uuid"
    },
    "is_public": {
      "type": "boolean"
    },
    "workspace_id": {
      "type": "string",
      "format": "uuid",
      "description": "The workspace this document belongs to (via its folder)."
    },
    "path": {
      "type": "array",
      "description": "Full path from the workspace root down to this document, workspace first, document last.",
      "items": {
        "$ref": "#/$defs/PathSegment"
      }
    },
    "path_string": {
      "type": "string",
      "description": "Path segment names joined by \" / \"."
    },
    "body": {
      "type": "string",
      "description": "Markdown document body."
    },
    "compounded_description": {
      "type": "string",
      "description": "Labeled cascade of descriptions from the workspace down through each ancestor folder to this document's folder. Empty string when nothing in the chain has a description."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "PathSegment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "type"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "workspace",
            "folder",
            "document"
          ]
        }
      }
    }
  }
}