{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/openpublica-com/json-schema/openpublica-com-document-schema.json",
  "title": "Document",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/openpublica-com-openapi.json#/components/schemas/Document",
  "type": "object",
  "properties": {
    "document_id": {
      "type": "string"
    },
    "government_id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "converted",
        "superseded",
        "failed"
      ],
      "description": "`converted` is served and searchable. `superseded` is retired by a newer edition, stored but not searchable. `failed` means WE HOLD THIS PIN AND COULD NOT READ IT — not that the government published nothing."
    },
    "element": {
      "type": [
        "string",
        "null"
      ],
      "description": "The slot whose pin acquired this document."
    },
    "covers": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Every slot the document answers for. A city binding one general plan pins it as `combined` and it answers for all eight elements — reading `element` alone makes the rest look unpublished."
    },
    "page_count": {
      "type": [
        "integer",
        "null"
      ]
    },
    "source_url": {
      "type": "string",
      "format": "uri",
      "description": "Always the government's own copy. Cite it, especially on a failed entry."
    },
    "markdown_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "availability": {
      "$ref": "#/$defs/DocumentAvailability"
    }
  },
  "$defs": {
    "DocumentAvailability": {
      "type": "object",
      "description": "Present ONLY when something is wrong — a clean document omits it, so its presence is the signal. Read it before quoting figures.",
      "properties": {
        "complete": {
          "type": "boolean"
        },
        "reason": {
          "type": "string",
          "description": "Drawn from a fixed caller-safe set."
        },
        "problems": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}