{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openjuvenile.org/schemas/v0.1/compatibility.schema.json",
  "title": "Compatibility module",
  "description": "Which products this product can be combined with: which seat fits which stroller, with which adapter, from which model year. Each entry is written from the point of view of the product the record describes.",
  "type": "object",
  "properties": {
    "compatibleWith": {
      "description": "Products this product can be combined with.",
      "type": "array",
      "items": {
        "description": "One compatibility statement.",
        "type": "object",
        "properties": {
          "target": {
            "description": "The other product: identified by GTIN, or by brand and model name when the statement covers all variants of a model.",
            "type": "object",
            "properties": {
              "gtin": {
                "$ref": "core.schema.json#/$defs/gtin",
                "description": "GTIN of the other product.",
                "x-openjuvenile-level": "conditional",
                "x-openjuvenile-condition": "brand and modelName are not given."
              },
              "brand": {
                "description": "Brand of the other product.",
                "type": "string",
                "minLength": 1,
                "x-openjuvenile-level": "conditional",
                "x-openjuvenile-condition": "gtin is not given.",
                "examples": ["Example Brand"]
              },
              "modelName": {
                "description": "Model name of the other product.",
                "type": "string",
                "minLength": 1,
                "x-openjuvenile-level": "conditional",
                "x-openjuvenile-condition": "gtin is not given.",
                "examples": ["Pebble Infant Car Seat"]
              }
            },
            "additionalProperties": false,
            "anyOf": [{ "required": ["gtin"] }, { "required": ["brand", "modelName"] }]
          },
          "relation": {
            "description": "fits-on: this product mounts on the target without additional parts · requires-adapter: the two products can be combined with the adapter given in adapter · replaces: this product replaces the target, for example as successor or spare part · accessory-for: this product is an accessory for the target.",
            "type": "string",
            "enum": ["fits-on", "requires-adapter", "replaces", "accessory-for"],
            "examples": ["requires-adapter"]
          },
          "adapter": {
            "description": "The adapter needed for the combination.",
            "type": "object",
            "properties": {
              "gtin": {
                "$ref": "core.schema.json#/$defs/gtin",
                "description": "GTIN of the adapter.",
                "x-openjuvenile-level": "should"
              },
              "modelName": {
                "description": "Model name of the adapter.",
                "type": "string",
                "minLength": 1,
                "x-openjuvenile-level": "conditional",
                "x-openjuvenile-condition": "gtin is not given.",
                "examples": ["Pebble Car Seat Adapter"]
              }
            },
            "additionalProperties": false,
            "anyOf": [{ "required": ["gtin"] }, { "required": ["modelName"] }],
            "x-openjuvenile-level": "conditional",
            "x-openjuvenile-condition": "relation is requires-adapter."
          },
          "validFromModelYear": {
            "description": "First model year of the target the statement applies to.",
            "type": "integer",
            "minimum": 1990,
            "maximum": 2100,
            "x-openjuvenile-level": "may",
            "examples": [2026]
          },
          "notes": {
            "$ref": "core.schema.json#/$defs/localizedString",
            "description": "Additional notes, for example on orientation or restrictions, per language.",
            "x-openjuvenile-level": "may"
          }
        },
        "required": ["target", "relation"],
        "additionalProperties": false,
        "if": {
          "properties": { "relation": { "const": "requires-adapter" } },
          "required": ["relation"]
        },
        "then": { "required": ["adapter"] }
      },
      "minItems": 1,
      "x-openjuvenile-level": "may"
    }
  },
  "patternProperties": {
    "^x-": {
      "description": "Extension fields. Names start with x- and are ignored by consumers that do not know them."
    }
  },
  "additionalProperties": false
}
