{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/findings.json",
  "title": "Finding document",
  "description": "The document served at /api/v1/findings.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "findings"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every finding this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Finding",
      "description": "Arithmetic over this record, with the computation that produced it. Never a judgment.",
      "properties": {
        "id": {
          "type": "string",
          "description": "The identifier of this finding."
        },
        "finding_type": {
          "type": "string",
          "description": "The kind of arithmetic."
        },
        "headline": {
          "type": "string",
          "description": "The finding, stated as a measurement."
        },
        "value": {
          "type": [
            "number",
            "string",
            "null"
          ],
          "description": "The figure."
        },
        "method": {
          "type": "string",
          "description": "The computation the figure came from. It travels with the number, so a reader can re-derive it."
        },
        "question": {
          "type": [
            "string",
            "null"
          ],
          "description": "The question the computation answers, as its writer stated it. Null where no writer stated one."
        },
        "population": {
          "type": [
            "string",
            "null"
          ],
          "description": "The set the computation counted over, as its writer stated it. Null where no writer stated one."
        },
        "limitation": {
          "type": [
            "string",
            "null"
          ],
          "description": "What bounds the figure, stated by the computation that produced it. Null where it stated none."
        },
        "figures": {
          "type": [
            "object",
            "null"
          ],
          "description": "Every number this finding publishes, by name. Null where it names none. A figure counted over a population this finding records as zero is not measured, and is null."
        },
        "data_window_start": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The first day of the data the computation read."
        },
        "data_window_end": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The last day of the data the computation read."
        },
        "computed_at": {
          "type": "string",
          "format": "date",
          "description": "The day it was computed."
        },
        "instruments_involved": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The rows the computation ran over."
        },
        "superseded_by": {
          "type": [
            "string",
            "null"
          ],
          "description": "The finding that replaced this one, where one has."
        }
      },
      "required": [
        "id",
        "headline",
        "method",
        "computed_at"
      ],
      "additionalProperties": true
    }
  }
}
