Resources/Schemas/v1/avm-modules-catalog.schema.json

{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "$id": "https://raw.githubusercontent.com/Azure/azure-verified-modules-tools/main/src/Avm.Authoring/Resources/Schemas/v1/avm-modules-catalog.schema.json",
  "title": "AVM combined module catalog v1",
  "type": "object",
  "additionalProperties": false,
  "required": [ "$schema", "schemaVersion", "modules" ],
  "properties": {
    "$schema": {
      "const": "https://raw.githubusercontent.com/Azure/azure-verified-modules-tools/main/src/Avm.Authoring/Resources/Schemas/v1/avm-modules-catalog.schema.json"
    },
    "schemaVersion": { "const": 1 },
    "modules": {
      "type": "object",
      "propertyNames": { "$ref": "#/definitions/canonicalType" },
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": [ "bicep", "terraform" ],
        "properties": {
          "bicep": {
            "type": "array",
            "items": {
              "allOf": [
                { "$ref": "#/definitions/module" },
                { "properties": { "ecosystem": { "const": "bicep" } } }
              ]
            }
          },
          "terraform": {
            "type": "array",
            "items": {
              "allOf": [
                { "$ref": "#/definitions/module" },
                { "properties": { "ecosystem": { "const": "terraform" } } }
              ]
            }
          }
        },
        "anyOf": [
          { "properties": { "bicep": { "minItems": 1 } } },
          { "properties": { "terraform": { "minItems": 1 } } }
        ]
      }
    }
  },
  "definitions": {
    "canonicalType": {
      "type": "string",
      "pattern": "^((Microsoft\\.[A-Z]\\w+|Oracle\\.Database)(/[a-zA-Z]\\w*)+|[a-z0-9-]+(/[a-z0-9-]+)*)$"
    },
    "nullableText": { "type": [ "string", "null" ] },
    "version": {
      "type": [ "string", "null" ],
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z.-]+)?(\\+[0-9A-Za-z.-]+)?$"
    },
    "owners": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "anyOf": [
          {
            "maxLength": 39,
            "pattern": "^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$"
          },
          {
            "pattern": "^@[A-Za-z0-9]+(-[A-Za-z0-9]+)*/[a-z0-9]+(-[a-z0-9]+)*$"
          }
        ]
      }
    },
    "registry": {
      "type": "object",
      "additionalProperties": false,
      "required": [ "status", "currentVersion", "firstPublishedIn", "downloads", "marRegistered" ],
      "properties": {
        "status": { "enum": [ "available", "not-published" ] },
        "currentVersion": { "$ref": "#/definitions/version" },
        "firstPublishedIn": {
          "type": [ "string", "null" ],
          "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"
        },
        "downloads": { "type": [ "integer", "null" ], "minimum": 0 },
        "marRegistered": { "type": [ "boolean", "null" ] }
      },
      "allOf": [
        {
          "if": { "properties": { "status": { "const": "available" } } },
          "then": {
            "properties": {
              "currentVersion": { "type": "string" },
              "firstPublishedIn": { "type": "string" }
            }
          },
          "else": {
            "properties": {
              "currentVersion": { "type": "null" },
              "firstPublishedIn": { "type": "null" },
              "downloads": { "type": "null" }
            }
          }
        }
      ]
    },
    "module": {
      "type": "object",
      "additionalProperties": false,
      "description": "Identity is (ecosystem, repository, modulePath), not canonicalType alone. Owner strings are usernames or qualified team handles.",
      "required": [
        "ecosystem", "moduleType", "moduleStatus", "moduleName", "modulePath", "repository",
        "repoURL", "parentModule", "familyModule", "provider",
        "canonicalType", "providerNamespace", "resourceType", "metadataSource",
        "moduleDisplayName", "moduleDescription", "alternativeNames", "comments",
        "owners", "telemetryIdPrefix", "publicRegistryReference", "registry"
      ],
      "properties": {
        "ecosystem": { "enum": [ "bicep", "terraform" ] },
        "moduleType": { "enum": [ "resource", "pattern", "utility" ] },
        "moduleStatus": { "enum": [ "Available", "Proposed", "Orphaned", "Deprecated" ] },
        "moduleName": { "type": "string", "minLength": 1 },
        "modulePath": { "type": "string", "minLength": 1 },
        "repository": {
          "type": "string",
          "pattern": "^Azure/[A-Za-z0-9][A-Za-z0-9_.-]*$"
        },
        "repoURL": { "type": "string", "pattern": "^https://github\\.com/Azure/" },
        "parentModule": { "$ref": "#/definitions/nullableText" },
        "familyModule": { "type": "string", "minLength": 1 },
        "provider": { "enum": [ null, "azurerm", "azapi", "azure" ] },
        "canonicalType": { "$ref": "#/definitions/canonicalType" },
        "providerNamespace": { "$ref": "#/definitions/nullableText" },
        "resourceType": { "$ref": "#/definitions/nullableText" },
        "metadataSource": { "const": "metadata" },
        "moduleDisplayName": { "type": "string" },
        "moduleDescription": { "type": "string" },
        "alternativeNames": { "type": "array", "items": { "type": "string" } },
        "comments": { "type": "string" },
        "owners": { "$ref": "#/definitions/owners" },
        "telemetryIdPrefix": { "$ref": "#/definitions/nullableText" },
        "publicRegistryReference": { "type": "string", "minLength": 1 },
        "registry": { "$ref": "#/definitions/registry" }
      },
      "allOf": [
        {
          "if": { "properties": { "ecosystem": { "const": "terraform" } } },
          "then": {
            "properties": {
              "repository": { "pattern": "^Azure/terraform-(azurerm|azapi|azure)-avm-(res|ptn|utl)-[a-z0-9-]+$" }
            }
          }
        },
        {
          "if": { "properties": { "metadataSource": { "const": "metadata" } } },
          "then": {
            "properties": {
              "moduleDisplayName": { "minLength": 1 },
              "moduleDescription": { "minLength": 1 }
            }
          }
        },
        {
          "if": { "properties": { "canonicalType": { "const": "helper" } } },
          "then": {
            "properties": {
              "parentModule": { "type": "string", "minLength": 1 },
              "providerNamespace": { "type": "null" },
              "resourceType": { "type": "null" }
            },
            "if": { "properties": { "ecosystem": { "const": "bicep" } } },
            "then": {
              "properties": {
                "modulePath": { "pattern": "^avm/(res|ptn|utl)/[a-z0-9-]+/[a-z0-9-]+(/[a-z0-9-]+)+$" }
              }
            },
            "else": {
              "properties": {
                "modulePath": { "pattern": "^modules/[a-z0-9_-]+$" },
                "parentModule": { "const": "." },
                "familyModule": { "const": "." }
              }
            }
          },
          "else": {
            "if": { "properties": { "moduleType": { "const": "resource" } } },
            "then": {
              "properties": {
                "canonicalType": { "pattern": "^(Microsoft\\.[A-Z]\\w+|Oracle\\.Database)(/[a-zA-Z]\\w*)+$" },
                "providerNamespace": { "type": "string" },
                "resourceType": { "type": "string" }
              }
            },
            "else": {
              "properties": {
                "canonicalType": { "pattern": "^[a-z0-9-]+(/[a-z0-9-]+)*$" },
                "providerNamespace": { "type": "null" },
                "resourceType": { "type": "null" }
              }
            }
          }
        }
      ]
    }
  }
}