{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cpaikr.github.io/fs/schema/0.2/snapshot-diff.schema.json",
  "title": "FS 0.2 validation snapshot diff",
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "required": ["formatVersion", "status"],
      "properties": {
        "formatVersion": { "const": "0.2" },
        "status": { "const": "not-recorded" }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": ["formatVersion", "status", "reason"],
      "properties": {
        "formatVersion": { "const": "0.2" },
        "status": { "const": "not-comparable" },
        "reason": { "const": "invalid-snapshot" }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": ["formatVersion", "status", "conformance", "calculations", "applications"],
      "properties": {
        "formatVersion": { "const": "0.2" },
        "status": { "enum": ["match", "mismatch"] },
        "conformance": { "$ref": "#/$defs/conformanceComparison" },
        "calculations": { "$ref": "#/$defs/calculationComparison" },
        "applications": {
          "type": "array",
          "items": { "$ref": "#/$defs/applicationChange" }
        }
      }
    }
  ],
  "$defs": {
    "conformanceComparison": {
      "type": "object",
      "additionalProperties": false,
      "required": ["recorded", "current"],
      "properties": {
        "recorded": { "enum": ["conforming", "nonconforming"] },
        "current": { "enum": ["conforming", "nonconforming"] }
      }
    },
    "calculationComparison": {
      "type": "object",
      "additionalProperties": false,
      "required": ["recorded", "current"],
      "properties": {
        "recorded": { "enum": ["not-run", "not-defined", "consistent", "inconsistent"] },
        "current": { "enum": ["not-run", "not-defined", "consistent", "inconsistent"] }
      }
    },
    "unchangedOrChanged": {
      "type": "object",
      "additionalProperties": false,
      "required": ["change", "recorded", "current"],
      "properties": {
        "change": { "enum": ["unchanged", "changed"] },
        "recorded": { "$ref": "fs-document.schema.json#/$defs/applicationResult" },
        "current": { "$ref": "fs-document.schema.json#/$defs/applicationResult" }
      }
    },
    "added": {
      "type": "object",
      "additionalProperties": false,
      "required": ["change", "current"],
      "properties": {
        "change": { "const": "added" },
        "current": { "$ref": "fs-document.schema.json#/$defs/applicationResult" }
      }
    },
    "removed": {
      "type": "object",
      "additionalProperties": false,
      "required": ["change", "recorded"],
      "properties": {
        "change": { "const": "removed" },
        "recorded": { "$ref": "fs-document.schema.json#/$defs/applicationResult" }
      }
    },
    "applicationChange": {
      "oneOf": [
        { "$ref": "#/$defs/unchangedOrChanged" },
        { "$ref": "#/$defs/added" },
        { "$ref": "#/$defs/removed" }
      ]
    }
  }
}
