{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://nwilbert.github.io/pytest-given/latest/schemas/report-v1.schema.json",
  "$defs": {
    "Attachment": {
      "additionalProperties": false,
      "properties": {
        "label": {
          "type": "string"
        },
        "content": {
          "type": "string"
        },
        "content_type": {
          "$ref": "#/$defs/ContentType",
          "default": "text"
        }
      },
      "required": [
        "label",
        "content",
        "content_type"
      ],
      "type": "object"
    },
    "AttachmentRef": {
      "additionalProperties": false,
      "properties": {
        "label": {
          "type": "string"
        },
        "content_type": {
          "$ref": "#/$defs/ContentType"
        },
        "column_id": {
          "description": "The parameter column whose cells hold the content, which varies by case.",
          "type": "string"
        }
      },
      "required": [
        "label",
        "content_type",
        "column_id"
      ],
      "type": "object"
    },
    "CaseIdentity": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "The case's ID, as the runner shows it.",
          "type": "string"
        },
        "node_id": {
          "description": "The runner's own ID of the case, which names it by its case ID, or one the recorder builds from the scenario ID and the case ID.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "node_id"
      ],
      "type": "object"
    },
    "CellValue": {
      "anyOf": [
        {
          "$ref": "#/$defs/ParamValue"
        },
        {
          "$ref": "#/$defs/Attachment"
        }
      ]
    },
    "Clause": {
      "additionalProperties": false,
      "properties": {
        "parts": {
          "items": {
            "$ref": "#/$defs/ClausePart"
          },
          "type": "array"
        }
      },
      "required": [
        "parts"
      ],
      "type": "object"
    },
    "ClausePart": {
      "anyOf": [
        {
          "$ref": "#/$defs/NarrationLiteral"
        },
        {
          "$ref": "#/$defs/NarrationTermRef"
        }
      ]
    },
    "ColumnKind": {
      "enum": [
        "param",
        "derived",
        "attachment"
      ],
      "type": "string"
    },
    "ContentType": {
      "enum": [
        "text",
        "json"
      ],
      "type": "string"
    },
    "Definition": {
      "additionalProperties": false,
      "properties": {
        "text": {
          "type": "string"
        },
        "parts": {
          "items": {
            "$ref": "#/$defs/DefinitionPart"
          },
          "type": "array"
        }
      },
      "required": [
        "text",
        "parts"
      ],
      "type": "object"
    },
    "DefinitionPart": {
      "anyOf": [
        {
          "$ref": "#/$defs/NarrationLiteral"
        },
        {
          "$ref": "#/$defs/NarrationTermRef"
        }
      ]
    },
    "ErrorCause": {
      "additionalProperties": false,
      "properties": {
        "frames": {
          "items": {
            "$ref": "#/$defs/TracebackFrame"
          },
          "type": "array"
        },
        "error_tail": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "What the language or runner prints below the frames: the exception's type and message, then any detail such as an assertion diff."
        },
        "connector": {
          "description": "The sentence that joins this exception to the next one of the chain, as the recorder's language words it.",
          "type": "string"
        }
      },
      "required": [
        "frames",
        "error_tail",
        "connector"
      ],
      "type": "object"
    },
    "ErrorInfo": {
      "additionalProperties": false,
      "properties": {
        "message": {
          "description": "The error's own message, without its type: the headline a reader sees first, and empty where the error has none.",
          "type": "string"
        },
        "frames": {
          "items": {
            "$ref": "#/$defs/TracebackFrame"
          },
          "type": "array"
        },
        "error_tail": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "What the language or runner prints below the frames: the exception's type and message, then any detail such as an assertion diff."
        },
        "causes": {
          "items": {
            "$ref": "#/$defs/ErrorCause"
          },
          "type": "array"
        },
        "further": {
          "description": "The errors the same test recorded after this one, in order, each with an empty `further`: a soft assertion in another runner, or an exception that carries several failures. pytest records none.",
          "items": {
            "$ref": "#/$defs/ErrorInfo"
          },
          "type": "array"
        }
      },
      "required": [
        "message",
        "frames",
        "error_tail",
        "causes",
        "further"
      ],
      "type": "object"
    },
    "Glossary": {
      "additionalProperties": false,
      "properties": {
        "terms": {
          "items": {
            "$ref": "#/$defs/GlossaryTerm"
          },
          "type": "array"
        }
      },
      "required": [
        "terms"
      ],
      "type": "object"
    },
    "GlossaryTerm": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Derived from the canonical name: lowercased, each run of characters other than ASCII letters and digits folded to one `-`, and trimmed of `-` at both ends, so `Markdown glossary` is `markdown-glossary`. Citations and `term_id` name the term by it, so every recorder derives it the same way.",
          "type": "string"
        },
        "kind": {
          "anyOf": [
            {
              "$ref": "#/$defs/TermKind"
            },
            {
              "type": "null"
            }
          ],
          "description": "Null when no kind was declared or inferred."
        },
        "canonical": {
          "type": "string"
        },
        "definition": {
          "anyOf": [
            {
              "$ref": "#/$defs/Definition"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "source": {
          "anyOf": [
            {
              "$ref": "#/$defs/SourceLocation"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "section": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "avoid": {
          "default": [],
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "required": [
        "id",
        "kind",
        "canonical",
        "definition",
        "source",
        "section",
        "avoid"
      ],
      "type": "object"
    },
    "Metadata": {
      "additionalProperties": false,
      "properties": {
        "project": {
          "description": "The project's name, which the pytest recorder takes from the rootdir.",
          "type": "string"
        },
        "timestamp": {
          "format": "date-time",
          "type": "string"
        },
        "tools": {
          "description": "A language for each language the tests are written in, in the order the recorder first met them; the runtime at most once; the runner and the recorder once each; and the builder at most once. pytest-given is the recorder on a pytest run. A recorder that builds the report itself names no builder: that role is for a separate tool that built the report from what the recorder wrote, last.",
          "items": {
            "$ref": "#/$defs/Tool"
          },
          "type": "array"
        },
        "commit_sha": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The commit the run tested, which fills `{sha}` in a source-link template. Null where it is unknown."
        },
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The report's display name. Null shows `project` instead, which stays the name `{project}` fills in a source-link template."
        },
        "report_url": {
          "anyOf": [
            {
              "format": "uri",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The public URL the HTML report is served from: where the citations it copies link, and what `pytest-given citations` reads report links against. Null leaves the copied links alone."
        },
        "kind": {
          "const": "report",
          "default": "report",
          "type": "string"
        },
        "schema_version": {
          "$ref": "#/$defs/ReportSchemaVersion",
          "default": 1
        }
      },
      "required": [
        "project",
        "timestamp",
        "tools",
        "commit_sha",
        "title",
        "report_url",
        "kind",
        "schema_version"
      ],
      "type": "object"
    },
    "Narration": {
      "additionalProperties": false,
      "properties": {
        "text": {
          "type": "string"
        },
        "parts": {
          "default": [],
          "items": {
            "$ref": "#/$defs/NarrationPart"
          },
          "type": "array"
        }
      },
      "required": [
        "text",
        "parts"
      ],
      "type": "object"
    },
    "NarrationLiteral": {
      "additionalProperties": false,
      "properties": {
        "value": {
          "type": "string"
        }
      },
      "required": [
        "value"
      ],
      "type": "object"
    },
    "NarrationPart": {
      "anyOf": [
        {
          "$ref": "#/$defs/NarrationLiteral"
        },
        {
          "$ref": "#/$defs/NarrationValue"
        },
        {
          "$ref": "#/$defs/NarrationPlaceholder"
        },
        {
          "$ref": "#/$defs/NarrationTermRef"
        }
      ]
    },
    "NarrationPlaceholder": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "column_id": {
          "description": "The parameter column whose cells fill it in.",
          "type": "string"
        },
        "literal": {
          "default": false,
          "description": "The value shows exactly as it is: in monospace, with its whitespace kept.",
          "type": "boolean"
        },
        "phrases": {
          "anyOf": [
            {
              "$ref": "#/$defs/Phrases"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A Boolean worded by phrases: the token reads both, and a case shows the one its Boolean picks."
        }
      },
      "required": [
        "name",
        "column_id",
        "literal",
        "phrases"
      ],
      "type": "object"
    },
    "NarrationTermRef": {
      "additionalProperties": false,
      "properties": {
        "term_id": {
          "type": "string"
        },
        "display": {
          "type": "string"
        }
      },
      "required": [
        "term_id",
        "display"
      ],
      "type": "object"
    },
    "NarrationValue": {
      "additionalProperties": false,
      "properties": {
        "rendered": {
          "type": "string"
        }
      },
      "required": [
        "rendered"
      ],
      "type": "object"
    },
    "ParamValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ]
    },
    "ParameterCase": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "The case's ID, as the runner shows it, unique within its table.",
          "type": "string"
        },
        "node_id": {
          "description": "The runner's own ID of the case, which names it by its case ID, or one the recorder builds from the scenario ID and the case ID.",
          "type": "string"
        },
        "values": {
          "description": "One cell per column, in the order of the table's columns. What a cell holds depends on its column's kind. Null is no value.",
          "items": {
            "$ref": "#/$defs/CellValue"
          },
          "type": "array"
        },
        "status": {
          "$ref": "#/$defs/Status",
          "default": "passed"
        },
        "error": {
          "anyOf": [
            {
              "$ref": "#/$defs/ErrorInfo"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "custom_id": {
          "default": false,
          "description": "Whether the case's ID was written by hand, not generated by the runner from the case's values.",
          "type": "boolean"
        },
        "reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Why the case was skipped or expected to fail, as its status says. Null for any other status."
        }
      },
      "required": [
        "id",
        "node_id",
        "values",
        "status",
        "error",
        "custom_id",
        "reason"
      ],
      "type": "object"
    },
    "ParameterColumn": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "What a placeholder or an attachment badge points at, unique within its table. A param column's ID is its parameter's name; the `derived:` and `attachment:` prefixes are reserved for the generated columns, numbered per kind (`derived:0`).",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/ColumnKind"
        }
      },
      "required": [
        "id",
        "name",
        "kind"
      ],
      "type": "object"
    },
    "ParameterTable": {
      "additionalProperties": false,
      "properties": {
        "columns": {
          "items": {
            "$ref": "#/$defs/ParameterColumn"
          },
          "type": "array"
        },
        "cases": {
          "items": {
            "$ref": "#/$defs/ParameterCase"
          },
          "type": "array"
        }
      },
      "required": [
        "columns",
        "cases"
      ],
      "type": "object"
    },
    "Phase": {
      "enum": [
        "given",
        "when",
        "then"
      ],
      "type": "string"
    },
    "Phrases": {
      "additionalProperties": false,
      "properties": {
        "true": {
          "type": "string"
        },
        "false": {
          "type": "string"
        }
      },
      "required": [
        "true",
        "false"
      ],
      "type": "object"
    },
    "Pin": {
      "additionalProperties": false,
      "properties": {
        "story_id": {
          "type": "string"
        },
        "sentence_id": {
          "type": "integer"
        }
      },
      "required": [
        "story_id",
        "sentence_id"
      ],
      "type": "object"
    },
    "ReportSchemaVersion": {
      "const": 1,
      "type": "integer"
    },
    "Scenario": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "The test's identity, without any case. A grouped scenario's cases all share it.",
          "type": "string"
        },
        "narration": {
          "$ref": "#/$defs/Narration",
          "description": "The title as authored, without a per-case scenario's case ID."
        },
        "suite": {
          "description": "Where the scenario sits in its test suite, outermost first, as the recorder chose the levels: pytest writes the dotted module name's parts, a JavaScript recorder its directory, file and `describe` blocks. No segment is empty or holds \" \u203a \", which a flat display and a `#suite=` link join them with.",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "type": "array"
        },
        "case_identity": {
          "anyOf": [
            {
              "$ref": "#/$defs/CaseIdentity"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Only on a per-case scenario: the one case it narrates."
        },
        "slug": {
          "default": "",
          "description": "What `#scenario=<slug>` addresses the scenario by, unique within the report.",
          "pattern": "^[^&=+#%\\s]+$",
          "type": "string"
        },
        "tags": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "status": {
          "$ref": "#/$defs/Status",
          "default": "passed",
          "description": "How the scenario came out. `error` means the test could not reach a verdict on the behavior it checks, such as a fixture failing outside the test body. A runner maps its own outcomes onto these: a JUnit XML `<error>`, an NUnit `Error`, a Playwright `interrupted` and a failing `beforeAll` or `beforeEach` hook are `error`; a timeout is `failed`; a Jest `todo`, a Mocha `pending`, a Playwright `fixme`, a JUnit `@Disabled` and an aborted JUnit test are `skipped`; a Jest `test.failing`, a Vitest `test.fails`, a Playwright `test.fail()` or an RSpec `pending` that fails is `xfailed`. A retried test records its last attempt."
        },
        "duration_ms": {
          "default": 0,
          "minimum": 0,
          "type": "integer"
        },
        "steps": {
          "items": {
            "$ref": "#/$defs/Step"
          },
          "type": "array"
        },
        "parameters": {
          "anyOf": [
            {
              "$ref": "#/$defs/ParameterTable"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "error": {
          "anyOf": [
            {
              "$ref": "#/$defs/ErrorInfo"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Null on a grouped parametrized scenario, whose cases each hold their own."
        },
        "reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Why it was skipped or expected to fail, as its status says. Null for any other status, and on a grouped parametrized scenario, whose cases each hold their own."
        },
        "source": {
          "anyOf": [
            {
              "$ref": "#/$defs/SourceLocation"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "story_ids": {
          "default": [],
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "pins": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Pin"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Null when nothing pins it. An empty array when pinning turned narration matching off."
        }
      },
      "required": [
        "id",
        "narration",
        "suite",
        "case_identity",
        "slug",
        "tags",
        "status",
        "duration_ms",
        "steps",
        "parameters",
        "error",
        "reason",
        "source",
        "story_ids",
        "pins"
      ],
      "type": "object"
    },
    "Sentence": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "integer"
        },
        "clauses": {
          "items": {
            "$ref": "#/$defs/Clause"
          },
          "type": "array"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "id",
        "clauses",
        "name"
      ],
      "type": "object"
    },
    "SourceLocation": {
      "additionalProperties": false,
      "properties": {
        "relpath": {
          "description": "The file's POSIX path, relative to the project root.",
          "type": "string"
        },
        "line": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "relpath",
        "line"
      ],
      "type": "object"
    },
    "Status": {
      "enum": [
        "passed",
        "failed",
        "error",
        "skipped",
        "xfailed"
      ],
      "type": "string"
    },
    "Step": {
      "additionalProperties": false,
      "properties": {
        "phase": {
          "$ref": "#/$defs/Phase"
        },
        "narration": {
          "$ref": "#/$defs/Narration"
        },
        "children": {
          "items": {
            "$ref": "#/$defs/Step"
          },
          "type": "array"
        },
        "attachments": {
          "items": {
            "$ref": "#/$defs/StepAttachment"
          },
          "type": "array"
        },
        "pins": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Pin"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Null when nothing pins it. An empty array when pinning turned narration matching off."
        },
        "fixture_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "phase",
        "narration",
        "children",
        "attachments",
        "pins",
        "fixture_name"
      ],
      "type": "object"
    },
    "StepAttachment": {
      "anyOf": [
        {
          "$ref": "#/$defs/Attachment"
        },
        {
          "$ref": "#/$defs/AttachmentRef"
        }
      ]
    },
    "Story": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "sentences": {
          "items": {
            "$ref": "#/$defs/Sentence"
          },
          "type": "array"
        },
        "source": {
          "anyOf": [
            {
              "$ref": "#/$defs/SourceLocation"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "id",
        "title",
        "sentences",
        "source"
      ],
      "type": "object"
    },
    "TermKind": {
      "enum": [
        "actor",
        "object",
        "activity"
      ],
      "type": "string"
    },
    "Tool": {
      "additionalProperties": false,
      "properties": {
        "role": {
          "$ref": "#/$defs/ToolRole"
        },
        "name": {
          "type": "string"
        },
        "version": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Null where the recorder cannot know the tool's version."
        }
      },
      "required": [
        "role",
        "name",
        "version"
      ],
      "type": "object"
    },
    "ToolRole": {
      "enum": [
        "language",
        "runtime",
        "runner",
        "recorder",
        "builder"
      ],
      "type": "string"
    },
    "TracebackFrame": {
      "additionalProperties": false,
      "properties": {
        "path": {
          "type": "string"
        },
        "line": {
          "type": "integer"
        },
        "func": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "is_internal": {
          "description": "Marks frames of the runner, the recorder and the language's own libraries, which the UI hides by default.",
          "type": "boolean"
        }
      },
      "required": [
        "path",
        "line",
        "func",
        "code",
        "is_internal"
      ],
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "default": "https://nwilbert.github.io/pytest-given/latest/schemas/report-v1.schema.json",
      "type": "string"
    },
    "metadata": {
      "$ref": "#/$defs/Metadata"
    },
    "scenarios": {
      "items": {
        "$ref": "#/$defs/Scenario"
      },
      "type": "array"
    },
    "glossary": {
      "anyOf": [
        {
          "$ref": "#/$defs/Glossary"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "stories": {
      "default": [],
      "items": {
        "$ref": "#/$defs/Story"
      },
      "type": "array"
    }
  },
  "required": [
    "$schema",
    "metadata",
    "scenarios",
    "glossary",
    "stories"
  ],
  "type": "object"
}
