{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/good-grants/json-schema/good-grants-attachment-schema.json",
  "title": "Attachment",
  "description": "File attached to an application through an attachments-typed form tab.",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/good-grants-openapi.yaml#/components/schemas/Attachment",
  "type": "object",
  "properties": {
    "application": {
      "type": "object",
      "description": "Application the attachment belongs to.",
      "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 as submitted by the applicant."
        }
      }
    },
    "attachment_fields": {
      "type": "array",
      "description": "Form fields captured against this attachment, one item per field, in form order.",
      "items": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "description": "Short URL-safe identifier for the field."
          },
          "link": {
            "type": "string",
            "format": "uri",
            "description": "Canonical URL for the field resource."
          },
          "label": {
            "type": "object",
            "description": "Display label shown to the applicant, may contain HTML or be empty, keyed by locale code.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "title": {
            "type": "object",
            "description": "Short title used to refer to the field in administrative contexts, keyed by locale code.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "value": {
            "type": "string",
            "description": "Raw stored value for the field, as submitted by the applicant."
          },
          "translated": {
            "type": "object",
            "description": "Human-readable rendering of `value` resolved against the field definition, keyed by locale code.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "download": {
            "type": "string",
            "format": "uri",
            "description": "Time-limited download URL, present only for file-typed fields with an underlying file."
          }
        }
      }
    },
    "created": {
      "type": "string",
      "format": "date-time",
      "description": "Date and time when the attachment was created."
    },
    "file": {
      "type": "object",
      "description": "File backing the attachment.",
      "properties": {
        "token": {
          "type": "string",
          "description": "Token identifying the file."
        },
        "link": {
          "type": "string",
          "format": "uri",
          "description": "Canonical URL for the file resource."
        },
        "download": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "Time-limited download URL for the underlying file, or `null` when no signed URL can be resolved."
        },
        "filename": {
          "type": "string",
          "description": "Original filename as uploaded."
        }
      }
    },
    "order": {
      "type": "integer",
      "description": "Position of the attachment within its tab."
    },
    "tab": {
      "type": "object",
      "description": "Attachments tab the attachment belongs to.",
      "properties": {
        "slug": {
          "type": "string",
          "description": "Short URL-safe identifier for the tab."
        },
        "link": {
          "type": "string",
          "format": "uri",
          "description": "Canonical URL for the tab resource."
        },
        "name": {
          "type": "object",
          "description": "Name of the tab, keyed by locale code.",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "token": {
      "type": "string",
      "description": "Token identifying the attachment file, same value as `file.token`."
    },
    "updated": {
      "type": "string",
      "format": "date-time",
      "description": "Date and time when the attachment was last updated."
    }
  }
}