{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://docs.allegrocdp.com/template.schema.json",
    "title": "Allegro template.json",
    "description": "Schema for the template.json manifest that accompanies an Allegro template directory.",
    "type": "object",
    "required": ["name", "fields"],
    "additionalProperties": true,
    "properties": {
        "name": {
            "type": "string",
            "minLength": 1,
            "description": "Display name (title) of the template. Used as the template title when synced from GitHub."
        },
        "fields": {
            "type": "array",
            "description": "Editable fields exposed by the template.",
            "items": { "$ref": "#/$defs/field" }
        }
    },
    "$defs": {
        "field": {
            "type": "object",
            "required": ["slug", "type"],
            "additionalProperties": false,
            "properties": {
                "slug": {
                    "type": "string",
                    "pattern": "^[a-z0-9_-]+$",
                    "description": "Identifier used as the placeholder token in the template markup."
                },
                "type": {
                    "enum": ["text", "number", "checkbox"],
                    "description": "Input type for the field."
                },
                "label": {
                    "type": "string",
                    "description": "Human-readable label shown in the editor. Used as the field description on sync."
                },
                "default_value": {
                    "description": "Initial value used by the local preview editor."
                },
                "description": {
                    "type": "string",
                    "description": "Help text. Used as the field description on sync when no label is set."
                }
            }
        }
    }
}
