{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "TomlLockfile",
  "description": "Serialization of `Cargo.lock`",
  "type": "object",
  "properties": {
    "version": {
      "description": "The lockfile format version (`version =` field).\n\nThis field is optional for backward compatibility. Older lockfiles, i.e. V1 and V2, does\nnot have the version field serialized.",
      "type": [
        "integer",
        "null"
      ],
      "format": "uint32",
      "minimum": 0
    },
    "package": {
      "description": "The list of `[[package]]` entries describing each resolved dependency.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/TomlLockfileDependency"
      }
    },
    "root": {
      "description": "The `[root]` table describing the root package.\n\nThis field is optional for backward compatibility. Older lockfiles have the root package\nseparated, whereas newer lockfiles have the root package as part of `[[package]]`.",
      "anyOf": [
        {
          "$ref": "#/$defs/TomlLockfileDependency"
        },
        {
          "type": "null"
        }
      ]
    },
    "metadata": {
      "description": "The `[metadata]` table\n\n\nIn older lockfile versions, dependency checksums were stored here instead of alongside each\npackage entry.",
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      }
    },
    "patch": {
      "description": "The `[patch]` table describing unused patches.\n\nThe lockfile stores them as a list of `[[patch.unused]]` entries.",
      "$ref": "#/$defs/TomlLockfilePatch"
    }
  },
  "$defs": {
    "TomlLockfileDependency": {
      "description": "Serialization of lockfiles dependencies",
      "type": "object",
      "properties": {
        "name": {
          "description": "The name of the dependency.",
          "type": "string"
        },
        "version": {
          "description": "The version of the dependency.",
          "type": "string"
        },
        "source": {
          "description": "The source of the dependency.\n\nCargo does not serialize path dependencies.",
          "anyOf": [
            {
              "$ref": "#/$defs/TomlLockfileSourceId"
            },
            {
              "type": "null"
            }
          ]
        },
        "checksum": {
          "description": "The checksum of the dependency.\n\nIn older lockfiles, checksums were not stored here and instead on a separate `[metadata]`\ntable (see [`TomlLockfileMetadata`]).",
          "type": [
            "string",
            "null"
          ]
        },
        "dependencies": {
          "description": "The transitive dependencies used by this dependency.",
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/TomlLockfilePackageId"
          }
        },
        "replace": {
          "description": "The replace of the dependency.",
          "anyOf": [
            {
              "$ref": "#/$defs/TomlLockfilePackageId"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "name",
        "version"
      ]
    },
    "TomlLockfileSourceId": {
      "description": "Serialization of dependency's source",
      "type": "string"
    },
    "TomlLockfilePackageId": {
      "description": "Serialization of package IDs.\n\nThe version and source are only included when necessary to disambiguate between packages:\n- If multiple packages share the same name, the version is included.\n- If multiple packages share the same name and version, the source is included.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "anyOf": [
            {
              "$ref": "#/$defs/TomlLockfileSourceId"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "TomlLockfilePatch": {
      "description": "Serialization of unused patches\n\nCargo stores patches that were declared but not used during resolution.",
      "type": "object",
      "properties": {
        "unused": {
          "description": "The list of unused dependency patches.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TomlLockfileDependency"
          }
        }
      },
      "required": [
        "unused"
      ]
    }
  }
}