{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openitsmhub.com/schema/openitsmhub-1.0.schema.json",
  "title": "Open ITSM Hub listing 1.0",
  "description": "Author file openitsmhub.yml, openitsmhub.md, openitsmhub.mdx, or the openitsmhub mapping inside package.yml. Version 1.0.",
  "type": "object",
  "$defs": {
    "language": {
      "type": "string",
      "pattern": "^[a-z]{2}(?:-[a-z]{2})?$"
    },
    "text": {
      "type": "string",
      "minLength": 1
    },
    "localeText": {
      "oneOf": [
        { "$ref": "#/$defs/text" },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": { "$ref": "#/$defs/language" },
          "additionalProperties": { "$ref": "#/$defs/text" }
        }
      ]
    },
    "httpUrl": {
      "type": "string",
      "minLength": 8,
      "maxLength": 2000,
      "pattern": "^https?://[^\\s]+$"
    },
    "acquisition": {
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "free",
            "open-source",
            "paid",
            "subscription",
            "quote",
            "included"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "model": {
              "type": "string",
              "enum": [
                "free",
                "open-source",
                "paid",
                "subscription",
                "quote",
                "included"
              ]
            },
            "type": {
              "type": "string",
              "enum": [
                "free",
                "open-source",
                "paid",
                "subscription",
                "quote",
                "included"
              ],
              "description": "Alias of model. Prefer model."
            },
            "price": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000000
            },
            "currency": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$"
            },
            "cycle": {
              "type": "string",
              "enum": ["one-time", "monthly", "yearly", "contract"]
            },
            "url": { "$ref": "#/$defs/httpUrl" },
            "note": { "$ref": "#/$defs/localeText" }
          }
        }
      ]
    },
    "link": {
      "oneOf": [
        { "$ref": "#/$defs/httpUrl" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["url"],
          "properties": {
            "title": { "$ref": "#/$defs/localeText" },
            "label": { "$ref": "#/$defs/localeText" },
            "name": { "$ref": "#/$defs/localeText" },
            "url": { "$ref": "#/$defs/httpUrl" }
          }
        }
      ]
    },
    "screenshot": {
      "oneOf": [
        { "$ref": "#/$defs/httpUrl" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["url"],
          "properties": {
            "url": { "$ref": "#/$defs/httpUrl" },
            "alt": { "type": "string", "maxLength": 200 },
            "alt_text": { "type": "string", "maxLength": 200 },
            "is_primary": { "type": "boolean" }
          }
        }
      ]
    }
  },
  "additionalProperties": false,
  "properties": {
    "title": { "$ref": "#/$defs/text" },
    "summary": { "$ref": "#/$defs/localeText" },
    "full_description": { "$ref": "#/$defs/localeText" },
    "overview_content": { "$ref": "#/$defs/localeText" },
    "categories": {
      "type": "array",
      "items": { "$ref": "#/$defs/text" }
    },
    "homepage": { "$ref": "#/$defs/httpUrl" },
    "logo": { "$ref": "#/$defs/httpUrl" },
    "license": { "$ref": "#/$defs/text" },
    "acquisition": { "$ref": "#/$defs/acquisition" },
    "links": {
      "type": "array",
      "maxItems": 20,
      "items": { "$ref": "#/$defs/link" }
    },
    "screenshots": {
      "type": "array",
      "maxItems": 100,
      "items": { "$ref": "#/$defs/screenshot" }
    },
    "developer": { "$ref": "#/$defs/text" },
    "skin_type": {
      "type": "string",
      "enum": ["agent", "customer", "both"]
    },
    "lang": { "$ref": "#/$defs/language" },
    "is_free": { "type": "boolean" },
    "youtube_demo_url": { "$ref": "#/$defs/httpUrl" }
  },
  "patternProperties": {
    "^(?:summary|full_description|overview_content)_[a-z]{2}(?:-[a-z]{2})?$": {
      "$ref": "#/$defs/text"
    }
  }
}
