{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.ferretlang.org/registry/artifact/api-catalog/v1.json",
  "title": "Ferret API Catalog Artifact v1",
  "description": "Presentation grouping paired with one immutable Ferret API Reference artifact.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "id",
    "version",
    "categories"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "id": {
      "$ref": "https://schemas.ferretlang.org/common/identifier.json"
    },
    "version": {
      "$ref": "https://schemas.ferretlang.org/common/semver.json"
    },
    "categories": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/category"
      }
    }
  },
  "$defs": {
    "categorySlug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
    },
    "ferretIdentifier": {
      "type": "string",
      "pattern": "^[A-Za-z][A-Za-z0-9_]*$"
    },
    "nonblankText": {
      "type": "string",
      "minLength": 1,
      "pattern": ".*\\S.*"
    },
    "functionReference": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "namespace",
        "name"
      ],
      "properties": {
        "namespace": {
          "oneOf": [
            {
              "const": ""
            },
            {
              "$ref": "https://schemas.ferretlang.org/common/namespace.json"
            }
          ]
        },
        "name": {
          "$ref": "#/$defs/ferretIdentifier"
        }
      }
    },
    "category": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "description",
        "functions"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/categorySlug"
        },
        "title": {
          "$ref": "#/$defs/nonblankText"
        },
        "description": {
          "$ref": "#/$defs/nonblankText"
        },
        "functions": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/functionReference"
          }
        }
      }
    }
  }
}
