{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://theamateur.co.uk/ai-journalism/api/v1/schema/edition.schema.json",
  "title": "AI Journalism edition",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "api_version",
    "section",
    "publisher",
    "edition",
    "title",
    "published_at",
    "updated_at",
    "week",
    "url",
    "api_url",
    "method",
    "lead_story_id",
    "story_count",
    "stories",
    "features",
    "corrections",
    "rights"
  ],
  "properties": {
    "schema": {
      "type": "string",
      "minLength": 1,
      "format": "uri"
    },
    "api_version": {
      "const": "1.0"
    },
    "section": {
      "const": "AI Journalism"
    },
    "publisher": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "url"
      ],
      "properties": {
        "name": {
          "const": "THE AMATEUR LIMITED"
        },
        "url": {
          "const": "https://theamateur.co.uk/"
        }
      }
    },
    "edition": {
      "type": "string",
      "minLength": 1,
      "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "published_at": {
      "type": "string",
      "minLength": 1,
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "minLength": 1,
      "format": "date-time"
    },
    "week": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "start",
        "end"
      ],
      "properties": {
        "start": {
          "type": "string",
          "minLength": 1,
          "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
        },
        "end": {
          "type": "string",
          "minLength": 1,
          "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
        }
      }
    },
    "url": {
      "type": "string",
      "minLength": 1,
      "format": "uri"
    },
    "api_url": {
      "type": "string",
      "minLength": 1,
      "format": "uri"
    },
    "method": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "discovery",
        "prose_author_model",
        "checking"
      ],
      "properties": {
        "discovery": {
          "type": "string",
          "minLength": 1
        },
        "prose_author_model": {
          "type": "string",
          "minLength": 1
        },
        "checking": {
          "const": "Each published claim is confirmed against a primary document; company figures stay attributed to the company."
        }
      }
    },
    "lead_story_id": {
      "type": "string",
      "minLength": 1
    },
    "story_count": {
      "const": 5
    },
    "stories": {
      "type": "array",
      "minItems": 5,
      "maxItems": 5,
      "items": {
        "$ref": "#/$defs/story"
      }
    },
    "features": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "slug",
          "api_url"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1
          },
          "api_url": {
            "type": "string",
            "minLength": 1,
            "format": "uri"
          }
        }
      }
    },
    "corrections": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "date",
          "text"
        ],
        "properties": {
          "date": {
            "type": "string",
            "minLength": 1,
            "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
          },
          "text": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "enum": [
              "correction",
              "response added",
              "update"
            ]
          }
        }
      }
    },
    "rights": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "text",
        "images_url"
      ],
      "properties": {
        "text": {
          "const": "Stories © THE AMATEUR LIMITED. You may quote short extracts with a credit and a link; ask before any other reuse (support@theamateur.co.uk)."
        },
        "images_url": {
          "const": "https://theamateur.co.uk/ai-journalism/images-and-licensing/"
        }
      }
    }
  },
  "$defs": {
    "image": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "role",
        "editorial_role",
        "url",
        "variants",
        "width",
        "height",
        "format",
        "sha256",
        "alt",
        "caption",
        "credit_line",
        "provenance_type",
        "photorealistic",
        "creator",
        "rights_holder",
        "copyright_notice",
        "licence",
        "attribution_required",
        "attribution_text",
        "reuse_by_agents",
        "source_url",
        "source_terms_url",
        "modifications",
        "depicts_real_event",
        "rights_checked"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "enum": [
            "hero",
            "inline",
            "teaser"
          ]
        },
        "editorial_role": {
          "enum": [
            "evidence",
            "identity",
            "geography",
            "mechanism",
            "contrast",
            "atmosphere"
          ]
        },
        "url": {
          "type": "string",
          "minLength": 1,
          "format": "uri"
        },
        "variants": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "url",
              "width",
              "height",
              "format"
            ],
            "properties": {
              "url": {
                "type": "string",
                "minLength": 1,
                "format": "uri"
              },
              "width": {
                "type": "integer",
                "minimum": 1
              },
              "height": {
                "type": "integer",
                "minimum": 1
              },
              "format": {
                "enum": [
                  "svg",
                  "webp",
                  "jpeg",
                  "png"
                ]
              }
            }
          }
        },
        "width": {
          "type": "integer",
          "minimum": 1
        },
        "height": {
          "type": "integer",
          "minimum": 1
        },
        "format": {
          "enum": [
            "svg",
            "webp",
            "jpeg",
            "png"
          ]
        },
        "sha256": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[a-f0-9]{64}$"
        },
        "alt": {
          "type": "string",
          "minLength": 1
        },
        "caption": {
          "type": "string",
          "minLength": 1
        },
        "credit_line": {
          "type": "string",
          "minLength": 1
        },
        "provenance_type": {
          "enum": [
            "original_diagram",
            "original_illustration",
            "original_illustration_generated",
            "original_photograph",
            "press_kit",
            "creative_commons",
            "public_domain"
          ]
        },
        "photorealistic": {
          "type": "boolean"
        },
        "digital_source_type": {
          "type": "string",
          "minLength": 1,
          "format": "uri"
        },
        "generated": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "tool",
                "requested_by"
              ],
              "properties": {
                "tool": {
                  "type": "string",
                  "minLength": 1
                },
                "requested_by": {
                  "const": "Justin Emmanuel"
                }
              }
            }
          ]
        },
        "creator": {
          "type": "string",
          "minLength": 1
        },
        "rights_holder": {
          "type": "string",
          "minLength": 1
        },
        "copyright_notice": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "minLength": 1
            }
          ]
        },
        "licence": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "id",
            "name",
            "url"
          ],
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1
            },
            "name": {
              "type": "string",
              "minLength": 1
            },
            "url": {
              "type": "string",
              "minLength": 1,
              "format": "uri"
            },
            "statement": {
              "const": "© THE AMATEUR LIMITED · Reuse only with permission (support@theamateur.co.uk)"
            }
          }
        },
        "attribution_required": {
          "type": "boolean"
        },
        "attribution_text": {
          "type": "string",
          "minLength": 1
        },
        "reuse_by_agents": {
          "enum": [
            "permission_required",
            "per_source_licence",
            "not_granted"
          ]
        },
        "source_url": {
          "type": "string",
          "minLength": 1,
          "format": "uri"
        },
        "source_terms_url": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "minLength": 1,
              "format": "uri"
            }
          ]
        },
        "modifications": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "depicts_real_event": {
          "type": "boolean"
        },
        "rights_checked": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "by",
            "on"
          ],
          "properties": {
            "by": {
              "const": "Editor (AI agent)"
            },
            "on": {
              "type": "string",
              "minLength": 1,
              "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
            }
          }
        },
        "edition": {
          "type": "string",
          "minLength": 1,
          "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
        },
        "story_id": {
          "type": "string",
          "minLength": 1
        },
        "feature_slug": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "story": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "edition",
        "position",
        "role",
        "kind",
        "kicker",
        "headline",
        "standfirst",
        "body",
        "word_count",
        "reading_minutes",
        "url",
        "api_url",
        "published_at",
        "updated_at",
        "sources",
        "images",
        "corrections"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "edition": {
          "type": "string",
          "minLength": 1,
          "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
        },
        "position": {
          "type": "integer",
          "minimum": 1
        },
        "role": {
          "enum": [
            "lead",
            "secondary"
          ]
        },
        "kind": {
          "const": "story"
        },
        "kicker": {
          "type": "string",
          "minLength": 1
        },
        "headline": {
          "type": "string",
          "minLength": 1
        },
        "standfirst": {
          "type": "string",
          "minLength": 1
        },
        "body": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "word_count": {
          "type": "integer",
          "minimum": 1
        },
        "reading_minutes": {
          "type": "integer",
          "minimum": 1
        },
        "url": {
          "type": "string",
          "minLength": 1,
          "format": "uri"
        },
        "api_url": {
          "type": "string",
          "minLength": 1,
          "format": "uri"
        },
        "published_at": {
          "type": "string",
          "minLength": 1,
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "minLength": 1,
          "format": "date-time"
        },
        "sources": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "role",
              "label",
              "url"
            ],
            "properties": {
              "role": {
                "enum": [
                  "primary",
                  "independent",
                  "discovery",
                  "reference"
                ]
              },
              "label": {
                "type": "string",
                "minLength": 1
              },
              "url": {
                "type": "string",
                "minLength": 1,
                "format": "uri"
              }
            }
          }
        },
        "images": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/image"
          }
        },
        "corrections": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "date",
              "text"
            ],
            "properties": {
              "date": {
                "type": "string",
                "minLength": 1,
                "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
              },
              "text": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "enum": [
                  "correction",
                  "response added",
                  "update"
                ]
              }
            }
          }
        }
      },
      "$defs": {
        "image": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "id",
            "role",
            "editorial_role",
            "url",
            "variants",
            "width",
            "height",
            "format",
            "sha256",
            "alt",
            "caption",
            "credit_line",
            "provenance_type",
            "photorealistic",
            "creator",
            "rights_holder",
            "copyright_notice",
            "licence",
            "attribution_required",
            "attribution_text",
            "reuse_by_agents",
            "source_url",
            "source_terms_url",
            "modifications",
            "depicts_real_event",
            "rights_checked"
          ],
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1
            },
            "role": {
              "enum": [
                "hero",
                "inline",
                "teaser"
              ]
            },
            "editorial_role": {
              "enum": [
                "evidence",
                "identity",
                "geography",
                "mechanism",
                "contrast",
                "atmosphere"
              ]
            },
            "url": {
              "type": "string",
              "minLength": 1,
              "format": "uri"
            },
            "variants": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "url",
                  "width",
                  "height",
                  "format"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "format": "uri"
                  },
                  "width": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "height": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "format": {
                    "enum": [
                      "svg",
                      "webp",
                      "jpeg",
                      "png"
                    ]
                  }
                }
              }
            },
            "width": {
              "type": "integer",
              "minimum": 1
            },
            "height": {
              "type": "integer",
              "minimum": 1
            },
            "format": {
              "enum": [
                "svg",
                "webp",
                "jpeg",
                "png"
              ]
            },
            "sha256": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[a-f0-9]{64}$"
            },
            "alt": {
              "type": "string",
              "minLength": 1
            },
            "caption": {
              "type": "string",
              "minLength": 1
            },
            "credit_line": {
              "type": "string",
              "minLength": 1
            },
            "provenance_type": {
              "enum": [
                "original_diagram",
                "original_illustration",
                "original_illustration_generated",
                "original_photograph",
                "press_kit",
                "creative_commons",
                "public_domain"
              ]
            },
            "photorealistic": {
              "type": "boolean"
            },
            "digital_source_type": {
              "type": "string",
              "minLength": 1,
              "format": "uri"
            },
            "generated": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "tool",
                    "requested_by"
                  ],
                  "properties": {
                    "tool": {
                      "type": "string",
                      "minLength": 1
                    },
                    "requested_by": {
                      "const": "Justin Emmanuel"
                    }
                  }
                }
              ]
            },
            "creator": {
              "type": "string",
              "minLength": 1
            },
            "rights_holder": {
              "type": "string",
              "minLength": 1
            },
            "copyright_notice": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "string",
                  "minLength": 1
                }
              ]
            },
            "licence": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "name",
                "url"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "url": {
                  "type": "string",
                  "minLength": 1,
                  "format": "uri"
                },
                "statement": {
                  "const": "© THE AMATEUR LIMITED · Reuse only with permission (support@theamateur.co.uk)"
                }
              }
            },
            "attribution_required": {
              "type": "boolean"
            },
            "attribution_text": {
              "type": "string",
              "minLength": 1
            },
            "reuse_by_agents": {
              "enum": [
                "permission_required",
                "per_source_licence",
                "not_granted"
              ]
            },
            "source_url": {
              "type": "string",
              "minLength": 1,
              "format": "uri"
            },
            "source_terms_url": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "string",
                  "minLength": 1,
                  "format": "uri"
                }
              ]
            },
            "modifications": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "depicts_real_event": {
              "type": "boolean"
            },
            "rights_checked": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "by",
                "on"
              ],
              "properties": {
                "by": {
                  "const": "Editor (AI agent)"
                },
                "on": {
                  "type": "string",
                  "minLength": 1,
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
                }
              }
            },
            "edition": {
              "type": "string",
              "minLength": 1,
              "pattern": "^\\d{4}-\\d{2}-\\d{2}(-dryrun)?$"
            },
            "story_id": {
              "type": "string",
              "minLength": 1
            },
            "feature_slug": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    }
  }
}
