{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://driftsys.github.io/schemas/markspec/reference/v1.json",
  "title": "MarkSpec Reference",
  "description": "A reference entry for external standards, documents, or norms.",
  "type": "object",
  "required": ["displayId", "title", "source", "location"],
  "additionalProperties": false,
  "properties": {
    "displayId": {
      "type": "string",
      "pattern": "^[A-Za-z0-9-]{2,}$"
    },
    "title": {
      "type": "string"
    },
    "body": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "document": {
      "type": ["string", "null"]
    },
    "externalUrl": {
      "type": ["string", "null"],
      "format": "uri"
    },
    "status": {
      "type": ["string", "null"],
      "enum": ["active", "superseded", "withdrawn", null]
    },
    "supersededBy": {
      "type": ["string", "null"]
    },
    "source": {
      "type": "string",
      "enum": ["markdown", "doc-comment"]
    },
    "location": {
      "type": "object",
      "required": ["file", "line"],
      "additionalProperties": false,
      "properties": {
        "file": { "type": "string" },
        "line": { "type": "integer", "minimum": 1 },
        "column": { "type": "integer", "minimum": 1 }
      }
    },
    "attributes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["key", "value"],
        "additionalProperties": false,
        "properties": {
          "key": { "type": "string" },
          "value": { "type": "string" }
        }
      }
    },
    "labels": {
      "type": "array",
      "items": { "type": "string" }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "createdBy": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedBy": {
      "type": "string"
    },
    "links": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "referencedBy": {
          "type": "array",
          "items": { "$ref": "https://driftsys.github.io/schemas/markspec/link-target/v1.json" }
        }
      }
    },
    "url": {
      "type": "string"
    }
  }
}
