StructKit provides JSON schema validation to ensure your YAML configuration files are correctly structured. This helps catch errors early and provides IDE support with autocompletion.
The official schema is available at:
https://raw.githubusercontent.com/httpdss/structkit/main/struct-schema.json
- Install the YAML extension
- Add this to your workspace settings (
.vscode/settings.json):
{
"yaml.schemas": {
"https://raw.githubusercontent.com/httpdss/structkit/main/struct-schema.json": ".struct.yaml"
}
}This provides validation and autocompletion for all .struct.yaml files.
- Go to Settings → Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings
- Click + to add a new mapping
- Set Schema file or URL to:
https://raw.githubusercontent.com/httpdss/structkit/main/struct-schema.json - Set File path pattern to:
*.struct.yaml
If you have custom structures, generate a schema that includes them:
# Generate schema with custom structures
structkit generate-schema -s /path/to/custom/structures -o my-schema.json
# Use in VS Code settings
{
"yaml.schemas": {
"./my-schema.json": ".struct.yaml"
}
}The schema validates the following top-level properties:
Defines files to be created:
files:
- filename.txt:
content: "File contents"
permissions: "0644"
skip: false
skip_if_exists: false
file: "https://example.com/template.txt"Properties:
content(string): Inline file contentpermissions(string): Octal permissions (e.g., "0755")skip(boolean): Skip file creationskip_if_exists(boolean): Skip if file existsfile(string): External file URL or path
Defines folders and nested structures:
folders:
- path/to/folder:
struct: "structure-name"
with:
variable: "value"Properties:
struct(string|array): Structure name(s) to applywith(object): Variables to pass to the structure
Defines template variables:
variables:
- variable_name:
description: "Variable description"
type: "string"
default: "default_value"Properties:
description(string): Human-readable descriptiontype(string): Variable type (string, integer, boolean)default(any): Default value
Shell commands to run before generation:
pre_hooks:
- "echo 'Starting generation...'"
- "./scripts/prepare.sh"Shell commands to run after generation:
post_hooks:
- "npm install"
- "git init"# Validate a configuration file
structkit validate my-config.yamlimport json
import yaml
from jsonschema import validate
# Load schema
with open('struct-schema.json') as f:
schema = json.load(f)
# Load and validate config
with open('my-config.yaml') as f:
config = yaml.safe_load(f)
validate(config, schema) # Raises exception if invalid# ❌ Wrong - files should be array of objects
files:
README.md: "content"
# ✅ Correct
files:
- README.md:
content: "content"# ❌ Wrong - structkit property missing
folders:
- src/:
with:
name: "myapp"
# ✅ Correct
folders:
- src/:
struct: "project/node"
with:
name: "myapp"# ❌ Wrong - type should be string
variables:
- port:
type: number
default: 8080
# ✅ Correct
variables:
- port:
type: integer
default: 8080You can extend the base schema for custom validation:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allOf": [
{
"$ref": "https://raw.githubusercontent.com/httpdss/structkit/main/struct-schema.json"
},
{
"properties": {
"custom_section": {
"type": "object",
"properties": {
"custom_property": {"type": "string"}
}
}
}
}
]
}With schema validation enabled, you get:
- Real-time validation: Errors highlighted as you type
- Autocompletion: Suggested properties and values
- Documentation: Hover tooltips with property descriptions
- Structure guidance: Valid structure names and paths
- Check internet connection (for remote schema)
- Verify file path (for local schema)
- Restart IDE after configuration changes
- Check IDE logs for error messages
- Use
structkit validatecommand for detailed error messages - Check schema documentation for required properties
- Verify YAML syntax is correct
- Ensure structure names exist in your installation
- Use local schema files for better performance
- Consider schema caching in your IDE
- Limit schema complexity for large configurations
This schema system ensures your StructKit configurations are valid and provides a better development experience through IDE integration.