{
  "$schema": "http://json-schema.org/schema#",
  "$id": "http://btw.mangalam-research.org/schemas/wed/metadata.json",
  "title": "Metadata",
  "description": "A schema describing metadata for wed modes.",
  "definitions": {
    "generator": {
      "description": "The name of the software that generated the JSON.",
      "type": "string"
    },
    "date": {
      "description": "The date at which the file was generated.",
      "type": "string",
      "format": "date-time"
    },
    "version": {
      "description": "Records the version number of the format of the metadata file.",
      "type": "string"
    },
    "namespaces": {
      "description": "Prefix -> uri mapping of absolute namespaces.",
      "type": "object"
    },
    "elements": {
      "description": "An array of all elements in the schema.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "description": "The local name of the element.",
            "type": "string"
          },
          "ns": {
            "description": "The namespace URI of the element.",
            "type": "string"
          },
          "desc": {
            "description": "A short documentation string.",
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": ["name", "desc"]
      }
    },
    "inline": {
      "description": "An object determining which elements are inline.",
      "type": "object",
      "properties": {
        "method": {
          "description": "The method by which elements are addressed",
          "type": "string",
          "enum": ["name"]
        },
        "rules": {
          "type": "object",
          "additionalProperties": { "type": "boolean" }
        }
      },
      "required": ["method", "rules"],
      "additionalProperties": false
    },
    "dochtml": {
      "description": "Configuration of the online HTML documentation for the XML schema.",
      "type": "object",
      "properties": {
        "method": {
          "description": "The method by which the URL is generated.",
          "type": "string",
          "enum": ["simple-pattern"]
        },
        "pattern": {
          "description": "The pattern to use.",
          "type": "string"
        }
      },
      "required": ["method", "pattern"],
      "additionalProperties": false
    }
  },
  "type": "object",
  "oneOf": [
    {
      "properties": {
        "generator": { "$ref": "#/definitions/generator" },
        "date": { "$ref": "#/definitions/date" },
        "version": {
          "enum": ["1"]
        },
        "namespaces": { "$ref": "#/definitions/namespaces" },
        "elements": { "$ref": "#/definitions/elements" },
        "dochtml": {
          "description": "A URL to where the schema's documentation is stored.",
          "type": "string"
        }
      },
      "required": ["version"],
      "additionalProperties": false
    }, {
      "properties": {
        "generator": { "$ref": "#/definitions/generator" },
        "date": { "$ref": "#/definitions/date" },
        "version": {
          "enum": ["2"]
        },
        "namespaces": { "$ref": "#/definitions/namespaces" },
        "elements": { "$ref": "#/definitions/elements" },
        "inline": { "$ref": "#/definitions/inline" },
        "dochtml": { "$ref": "#/definitions/dochtml" }
      },
      "additionalProperties": false,
      "required": ["version", "namespaces"]
    }
  ]
}
