{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://answerkb.com/schema/news.schema.json",
  "title": "News brief answer twin",
  "description": "Schema for the answer.json twin of each /news/<topic>/latest/ page.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "kind",
    "topic",
    "question",
    "common_queries",
    "answer",
    "headline",
    "items",
    "as_of",
    "last_updated",
    "stale_after",
    "status",
    "disclaimer",
    "history",
    "canonical_url"
  ],
  "properties": {
    "id": { "type": "string", "minLength": 1, "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
    "kind": { "type": "string", "const": "news_brief" },
    "topic": { "type": "string", "minLength": 1 },
    "question": { "type": "string", "minLength": 1 },
    "common_queries": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 }
    },
    "answer": { "type": "string", "minLength": 1 },
    "headline": { "type": ["string", "null"], "minLength": 1 },
    "items": {
      "type": "array",
      "maxItems": 7,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["title", "summary", "source_name", "source_url", "published"],
        "properties": {
          "title": { "type": "string", "minLength": 1 },
          "summary": { "type": "string", "minLength": 1 },
          "source_name": { "type": "string", "minLength": 1 },
          "source_url": { "type": "string", "format": "uri" },
          "published": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" }
        }
      }
    },
    "as_of": { "type": ["string", "null"], "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
    "last_updated": { "type": ["string", "null"] },
    "stale_after": { "type": ["string", "null"] },
    "status": { "type": "string", "enum": ["awaiting", "fresh", "stale"] },
    "disclaimer": { "type": "string", "minLength": 1 },
    "history": {
      "type": "array",
      "maxItems": 14,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["as_of", "headline", "items"],
        "properties": {
          "as_of": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
          "headline": { "type": "string", "minLength": 1 },
          "items": {
            "type": "array",
            "maxItems": 7,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["title", "summary", "source_name", "source_url", "published"],
              "properties": {
                "title": { "type": "string", "minLength": 1 },
                "summary": { "type": "string", "minLength": 1 },
                "source_name": { "type": "string", "minLength": 1 },
                "source_url": { "type": "string", "format": "uri" },
                "published": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" }
              }
            }
          },
          "last_updated": { "type": ["string", "null"] },
          "reporter": { "type": ["string", "null"] },
          "note": { "type": ["string", "null"] }
        }
      }
    },
    "canonical_url": { "type": "string", "format": "uri" },
    "updated": { "type": "string", "format": "date" },
    "path": { "type": "string", "pattern": "^/" },
    "reporter": { "type": ["string", "null"] },
    "note": { "type": ["string", "null"] }
  }
}
