{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "passport.schema.json",
  "title": "Digital Product Passport",
  "description": "A Digital Product Passport record as returned by POST /v1/passports and GET /v1/passports/{id}.",
  "type": "object",
  "required": ["passportId", "uid", "category", "dataModelVersion", "status", "dataCarrier", "resolveUrl", "validation", "createdAt", "datasetVersions"],
  "additionalProperties": true,
  "properties": {
    "passportId": {
      "type": "string",
      "description": "Internal ULID for the passport record."
    },
    "uid": {
      "type": "string",
      "description": "Unique identifier conforming to ISO/IEC 15459, embedded in the data carrier and resolve URL."
    },
    "category": {
      "type": "string",
      "enum": ["battery-ev", "battery-lmt", "battery-industrial"]
    },
    "dataModelVersion": {
      "type": "string",
      "description": "Version of the data model used for validation."
    },
    "status": {
      "type": "string",
      "enum": ["draft", "issued", "registered", "amended"],
      "description": "Lifecycle status. draft=structurally valid but incomplete; issued=complete; registered=submitted to EU registry; amended=post-registration update recorded."
    },
    "dataCarrier": {
      "type": "object",
      "required": ["type", "standard", "payload"],
      "properties": {
        "type": { "type": "string", "enum": ["qr", "datamatrix", "nfc"] },
        "standard": { "type": "string" },
        "payload": { "type": "string", "description": "The resolvable URL encoded in the carrier." },
        "svg": { "type": "string", "description": "SVG rendering (qr and datamatrix only)." },
        "ndef": { "type": "string", "description": "NDEF URI record descriptor (nfc only)." }
      }
    },
    "resolveUrl": {
      "type": "string",
      "format": "uri",
      "description": "Stable public URL at which this passport resolves."
    },
    "validation": {
      "type": "object",
      "required": ["valid"],
      "properties": {
        "valid": { "type": "boolean" },
        "missing": { "type": "array", "items": { "type": "string" } },
        "invalid": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": { "type": "string" },
              "reason": { "type": "string" }
            }
          }
        },
        "warnings": { "type": "array", "items": { "type": "string" } }
      }
    },
    "attributes": {
      "type": "object",
      "description": "The submitted attribute values (owner view — all tiers).",
      "additionalProperties": true
    },
    "createdAt": { "type": "string", "format": "date-time" },
    "updatedAt": { "type": "string", "format": "date-time" },
    "version": { "type": "integer", "minimum": 1 },
    "registrationId": { "type": "string" },
    "registryEnvironment": { "type": "string", "enum": ["test", "production"] },
    "datasetVersions": {
      "type": "object",
      "required": ["dataModel", "accessTiers"],
      "properties": {
        "dataModel": { "type": "string" },
        "accessTiers": { "type": "string" },
        "registryMapping": { "type": "string" }
      }
    }
  }
}
