{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://readium.org/lcp-specs/schema/link.schema.json",
  "title": "Readium LCP Link",
  "type": "object",
  "properties": {
    "href": {
      "description": "URI or URI template of the linked resource",
      "type": "string"
    },
    "type": {
      "description": "MIME type of the linked resource",
      "type": "string"
    },
    "templated": {
      "description": "Indicates that a URI template is used in href",
      "type": "boolean"
    },
    "title": {
      "description": "Title of the linked resource",
      "type": "string"
    },
    "rel": {
      "description": "Relation between the linked resource and its containing collection",
      "type": [
        "string",
        "array"
      ],
      "items": {
        "type": "string"
      }
    },
    "profile": {
      "description": "Expected profile used to identify the external resource",
      "type": "string",
      "format": "uri"
    },
    "length": {
      "description": "Content length in octets",
      "type": "integer"
    },
    "hash": {
      "description": "SHA-256 hash of the resource",
      "type": "string",
      "contentEncoding": "base64"
    }
  },
  "required": [
    "href",
    "rel"
  ],
  "if": {
    "properties": {
      "templated": {
        "enum": [
          false,
          null
        ]
      }
    }
  },
  "then": {
    "properties": {
      "href": {
        "type": "string",
        "format": "uri"
      }
    }
  },
  "else": {
    "properties": {
      "href": {
        "type": "string",
        "format": "uri-template"
      }
    }
  }
}