{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mcbasic.org/schemas/component-sdk/api.schema.v1.json",
  "title": "McBasic Component SDK API metadata v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "apiVersion"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "apiVersion": { "const": "1.0" },
    "description": { "type": "string" },
    "properties": { "type": "array", "items": { "$ref": "#/$defs/property" } },
    "methods": { "type": "array", "items": { "$ref": "#/$defs/method" } },
    "events": { "type": "array", "items": { "$ref": "#/$defs/event" } },
    "designDefaults": {
      "type": "object",
      "additionalProperties": false,
      "required": ["Width", "Height", "Resizable"],
      "properties": {
        "Width": { "type": "number", "minimum": 0 },
        "Height": { "type": "number", "minimum": 0 },
        "Resizable": { "type": "boolean" }
      }
    }
  },
  "$defs": {
    "identifier": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
    "parameter": {
      "type": "object",
      "required": ["name", "type"],
      "properties": {
        "name": { "$ref": "#/$defs/identifier" },
        "type": { "type": "string", "minLength": 1 },
        "byRef": { "type": "boolean" },
        "optional": { "type": "boolean" },
        "paramArray": { "type": "boolean" },
        "defaultValue": {}
      }
    },
    "property": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "type", "readOnly", "description"],
      "properties": {
        "name": { "$ref": "#/$defs/identifier" },
        "type": { "type": "string", "minLength": 1 },
        "readOnly": { "type": "boolean" },
        "description": { "type": "string" },
        "signature": { "type": "string" },
        "defaultValue": { "type": ["string", "boolean", "number"] },
        "resetValue": { "type": ["string", "boolean", "number"] },
        "editor": { "enum": ["Text"] }
      }
    },
    "method": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "returnType", "parameters"],
      "properties": {
        "name": { "$ref": "#/$defs/identifier" },
        "returnType": { "type": "string", "minLength": 1 },
        "signature": { "type": "string" },
        "description": { "type": "string" },
        "async": { "type": "boolean" },
        "isAsync": { "type": "boolean" },
        "parameters": { "type": "array", "items": { "$ref": "#/$defs/parameter" } }
      }
    },
    "event": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "parameters"],
      "properties": {
        "name": { "$ref": "#/$defs/identifier" },
        "signature": { "type": "string" },
        "description": { "type": "string" },
        "parameters": { "type": "array", "items": { "$ref": "#/$defs/parameter" } }
      }
    }
  }
}
