{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/good-grants/json-schema/good-grants-document-list-schema.json",
  "title": "DocumentList",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/good-grants-documents-api-openapi.yml#/components/schemas/DocumentList",
  "allOf": [
    {
      "$ref": "#/$defs/Pagination"
    },
    {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Document"
          }
        }
      }
    }
  ],
  "$defs": {
    "Document": {
      "title": "Document",
      "description": "Document generated from a document template and attached to an application, allocation, or user.",
      "type": "object",
      "properties": {
        "allocation": {
          "description": "Allocation the document is attached to, or an empty array when not attached to one.",
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "slug": {
                  "type": "string",
                  "description": "Short URL-safe identifier for the allocation."
                },
                "link": {
                  "type": "string",
                  "format": "uri",
                  "description": "Canonical URL for the allocation resource."
                }
              }
            },
            {
              "type": "array",
              "maxItems": 0
            }
          ]
        },
        "application": {
          "description": "Application the document is attached to, or an empty array when not attached to one.",
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "slug": {
                  "type": "string",
                  "description": "Short URL-safe identifier for the application."
                },
                "link": {
                  "type": "string",
                  "format": "uri",
                  "description": "Canonical URL for the application resource."
                },
                "title": {
                  "type": "string",
                  "description": "Title of the application."
                }
              }
            },
            {
              "type": "array",
              "maxItems": 0
            }
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "Date and time when the document was created."
        },
        "description": {
          "type": "object",
          "description": "Description of the document, inherited from the document template, keyed by locale code.",
          "additionalProperties": {
            "type": "string"
          }
        },
        "file": {
          "type": "object",
          "description": "Generated document file.",
          "properties": {
            "token": {
              "type": "string",
              "description": "Token identifying the file."
            },
            "link": {
              "type": "string",
              "format": "uri",
              "description": "Canonical URL for the file resource."
            },
            "name": {
              "type": "string",
              "description": "Original filename of the generated document."
            },
            "download": {
              "type": "string",
              "format": "uri",
              "description": "Time-limited download URL for the file."
            }
          }
        },
        "file_type": {
          "type": "string",
          "enum": [
            "PDF",
            "Word"
          ],
          "description": "File format of the generated document."
        },
        "name": {
          "type": "object",
          "description": "Name of the document, keyed by locale code.",
          "additionalProperties": {
            "type": "string"
          }
        },
        "shared_with_user": {
          "type": "boolean",
          "description": "Specifies whether the document is shared with the applicant."
        },
        "slug": {
          "type": "string",
          "description": "URL-safe identifier of the document."
        },
        "user": {
          "description": "User who created the document, or an empty array when none is attached.",
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "slug": {
                  "type": "string",
                  "description": "Short URL-safe identifier for the user."
                },
                "link": {
                  "type": "string",
                  "format": "uri",
                  "description": "Canonical URL for the user resource."
                },
                "name": {
                  "type": "string",
                  "description": "Full name of the user."
                },
                "first_name": {
                  "type": "string",
                  "description": "First name of the user."
                },
                "last_name": {
                  "type": "string",
                  "description": "Last name of the user."
                }
              }
            },
            {
              "type": "array",
              "maxItems": 0
            }
          ]
        }
      }
    },
    "Pagination": {
      "type": "object",
      "title": "Pagination",
      "properties": {
        "current_page": {
          "type": "integer",
          "description": "Number of the page returned by this response, starting at `1`."
        },
        "first_page_url": {
          "type": "string",
          "description": "URL of the first page in the result set, relative when the requested page is beyond the last page."
        },
        "from": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Position of the first record on this page within the full result set, starting at `1`, or `null` when the requested page is beyond the last page."
        },
        "last_page": {
          "type": "integer",
          "description": "Total number of pages."
        },
        "last_page_url": {
          "type": "string",
          "description": "URL of the last page in the result set, relative when the requested page is beyond the last page."
        },
        "next_page_url": {
          "type": "string",
          "description": "URL of the next page in the result set, empty when the current page is the last page."
        },
        "path": {
          "type": "string",
          "description": "Canonical URL of the endpoint, without query parameters."
        },
        "per_page": {
          "type": "integer",
          "default": 10,
          "description": "Maximum number of records returned per page."
        },
        "prev_page_url": {
          "type": "string",
          "description": "URL of the previous page in the result set, empty when the current page is the first page."
        },
        "to": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Position of the last record on this page within the full result set, or `null` when the requested page is beyond the last page."
        },
        "total": {
          "type": "integer",
          "description": "Total number of records across all pages."
        }
      }
    }
  }
}