{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.ferretlang.org/registry/module/v1.json",
  "title": "Ferret Registry Module Manifest v1",
  "description": "A Ferret registry module identity and its public Git source.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "owner",
    "name",
    "source"
  ],
  "properties": {
    "$schema": {
      "const": "https://schemas.ferretlang.org/registry/module/v1.json"
    },
    "owner": {
      "$ref": "#/$defs/nameSegment"
    },
    "name": {
      "$ref": "#/$defs/nameSegment"
    },
    "source": {
      "$ref": "#/$defs/source"
    }
  },
  "$defs": {
    "nameSegment": {
      "type": "string",
      "pattern": "^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$"
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "repository"
      ],
      "properties": {
        "repository": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://[^/?#\\s]+/[^?#\\s]+$"
        },
        "path": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[^/\\\\\\r\\n]+(/[^/\\\\\\r\\n]+)*$"
        }
      }
    }
  }
}
