{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://b2base.eu/schemas/1.0.0-draft.1/contracts/contract.schema.json",
  "title": "Vertragsmetadaten",
  "$comment": "B2Base 1.0.0-draft.1. Projektentwurf, kein durch ISO oder andere Normungsgremien verabschiedeter Standard.",
  "type": "object",
  "description": "Metadaten eines Vertrags.",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "description": "Vertragskennung.",
      "format": "uri"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "description": "Bezeichnung."
    },
    "parties": {
      "type": "array",
      "description": "Vertragsparteien.",
      "items": {
        "$ref": "#/$defs/PartyRef"
      },
      "minItems": 1
    },
    "status": {
      "type": "string",
      "minLength": 1,
      "description": "Dokumentierter Bearbeitungsstatus.",
      "enum": [
        "draft",
        "active",
        "ended",
        "cancelled"
      ]
    },
    "validFrom": {
      "type": "string",
      "minLength": 1,
      "description": "Erster Geltungstag.",
      "format": "date"
    },
    "validUntil": {
      "type": "string",
      "minLength": 1,
      "description": "Letzter Geltungstag, falls befristet.",
      "format": "date"
    },
    "governingLaw": {
      "type": "string",
      "minLength": 1,
      "description": "Vereinbarte Rechtsordnung in Originalbezeichnung, falls bekannt."
    },
    "documentRefs": {
      "type": "array",
      "description": "Vertragsdokumente und Nachweise.",
      "items": {
        "type": "string",
        "minLength": 1,
        "description": "Dokument-URI.",
        "format": "uri"
      }
    },
    "extensions": {
      "type": "object",
      "description": "Vereinbarte Erweiterungen; Schlüssel als absolute URI des Herausgebers. Keine stillschweigende Änderung von Kernfeldern.",
      "properties": {},
      "additionalProperties": true,
      "propertyNames": {
        "format": "uri"
      }
    }
  },
  "required": [
    "id",
    "title",
    "parties",
    "status"
  ],
  "additionalProperties": false,
  "$defs": {
    "PartyRef": {
      "type": "object",
      "description": "Verweis auf eine separat gespeicherte Person oder juristische Person; kein JSON-Schema-Verweis.",
      "properties": {
        "entityType": {
          "type": "string",
          "minLength": 1,
          "description": "Art der referenzierten Einheit.",
          "enum": [
            "person",
            "legalEntity"
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Stabile absolute URI oder URN des Datensatzes, nicht dessen Name.",
          "format": "uri"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "description": "Optionale Anzeige; nicht als Identitätsschlüssel verwenden."
        }
      },
      "required": [
        "entityType",
        "id"
      ],
      "additionalProperties": false
    }
  },
  "examples": [
    {
      "id": "urn:example:contract:42",
      "title": "Service Agreement",
      "parties": [
        {
          "entityType": "legalEntity",
          "id": "urn:example:organisation:42"
        }
      ],
      "status": "draft",
      "documentRefs": [
        "urn:example:document:42"
      ]
    }
  ]
}
