{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openjuvenile.org/schemas/v0.2/media.schema.json",
  "title": "Media block",
  "description": "Images with defined roles, documents, videos and 3D/AR models. Media files are referenced by URL; the record does not contain the files themselves.",
  "type": "object",
  "properties": {
    "images": {
      "description": "Product images. At least one image has the role hero: it identifies the product in listings.",
      "type": "array",
      "items": {
        "description": "One image.",
        "type": "object",
        "properties": {
          "url": {
            "$ref": "core.schema.json#/$defs/url",
            "description": "URL of the image file."
          },
          "role": {
            "description": "Purpose of the image: hero (main image), packshot, lifestyle, detail, folded, dimension-drawing or packaging.",
            "type": "string",
            "enum": [
              "hero",
              "packshot",
              "lifestyle",
              "detail",
              "folded",
              "dimension-drawing",
              "packaging"
            ],
            "examples": ["hero"]
          },
          "altText": {
            "$ref": "core.schema.json#/$defs/localizedString",
            "description": "Text alternative that describes the image, per language.",
            "x-openjuvenile-level": "should"
          },
          "variantGtin": {
            "$ref": "core.schema.json#/$defs/gtin",
            "description": "GTIN of the variant shown, if the image shows a different variant than the record.",
            "x-openjuvenile-level": "may"
          },
          "widthPx": {
            "description": "Width of the image in pixels.",
            "type": "integer",
            "minimum": 1,
            "x-openjuvenile-level": "may",
            "examples": [2000]
          },
          "heightPx": {
            "description": "Height of the image in pixels.",
            "type": "integer",
            "minimum": 1,
            "x-openjuvenile-level": "may",
            "examples": [2000]
          }
        },
        "required": ["url", "role"],
        "additionalProperties": false
      },
      "minItems": 1,
      "contains": {
        "type": "object",
        "properties": {
          "role": {
            "const": "hero"
          }
        },
        "required": ["role"]
      }
    },
    "documents": {
      "description": "Documents for consumers and retailers, such as user manuals and declarations of conformity.",
      "type": "array",
      "items": {
        "description": "One document.",
        "type": "object",
        "properties": {
          "type": {
            "description": "Kind of document.",
            "type": "string",
            "enum": [
              "user-manual",
              "assembly-instructions",
              "declaration-of-conformity",
              "test-report",
              "safety-data-sheet",
              "spare-parts"
            ],
            "examples": ["user-manual"]
          },
          "url": {
            "$ref": "core.schema.json#/$defs/url",
            "description": "URL of the document file."
          },
          "language": {
            "$ref": "core.schema.json#/$defs/languageCode",
            "description": "Language of the document. Each entry has one language; add one entry per language version."
          }
        },
        "required": ["type", "url", "language"],
        "additionalProperties": false
      },
      "x-openjuvenile-level": "should"
    },
    "videos": {
      "description": "Product videos.",
      "type": "array",
      "items": {
        "description": "One video.",
        "type": "object",
        "properties": {
          "url": {
            "$ref": "core.schema.json#/$defs/url",
            "description": "URL of the video file or page."
          },
          "role": {
            "description": "Purpose of the video.",
            "$comment": "TODO(review): the list of video roles is a first draft.",
            "type": "string",
            "enum": ["overview", "folding", "assembly", "installation", "safety", "other"],
            "examples": ["folding"]
          },
          "language": {
            "$ref": "core.schema.json#/$defs/languageCode",
            "description": "Spoken or written language of the video, if any.",
            "x-openjuvenile-level": "may"
          }
        },
        "required": ["url", "role"],
        "additionalProperties": false
      },
      "x-openjuvenile-level": "may"
    },
    "models3d": {
      "description": "3D models for viewers and augmented reality, in real-world scale.",
      "type": "array",
      "items": {
        "description": "One 3D model.",
        "type": "object",
        "properties": {
          "glbUrl": {
            "$ref": "core.schema.json#/$defs/url",
            "description": "URL of the model as binary glTF (GLB)."
          },
          "usdzUrl": {
            "$ref": "core.schema.json#/$defs/url",
            "description": "URL of the model as USDZ, for AR on Apple devices.",
            "x-openjuvenile-level": "should"
          },
          "realWorldScale": {
            "description": "Whether the model is modelled in real-world scale.",
            "type": "boolean",
            "examples": [true]
          },
          "units": {
            "description": "Unit of the model coordinates. Always metres.",
            "type": "string",
            "const": "m",
            "examples": ["m"]
          },
          "variantGtins": {
            "description": "GTINs of the variants the model represents.",
            "type": "array",
            "items": {
              "$ref": "core.schema.json#/$defs/gtin",
              "description": "GTIN of one variant."
            },
            "minItems": 1,
            "x-openjuvenile-level": "should"
          },
          "polycount": {
            "description": "Number of polygons, to help consumers choose a suitable model.",
            "type": "integer",
            "minimum": 1,
            "x-openjuvenile-level": "may",
            "examples": [85000]
          },
          "arReady": {
            "description": "Whether the model is prepared for augmented reality viewers.",
            "type": "boolean",
            "x-openjuvenile-level": "should",
            "examples": [true]
          }
        },
        "required": ["glbUrl", "realWorldScale", "units"],
        "additionalProperties": false
      },
      "x-openjuvenile-level": "may"
    }
  },
  "required": ["images"],
  "patternProperties": {
    "^x-": {
      "description": "Extension fields. Names start with x- and are ignored by consumers that do not know them."
    }
  },
  "additionalProperties": false
}
