Generator Configuration
The Azu CLI provides a flexible configuration system for customizing code generation behavior. This document covers how to configure generators to match your project's conventions and requirements.
Overview
Generator configuration allows you to:
Customize generated code style and structure
Define project-specific naming conventions
Configure template paths and custom templates
Set default options for generators
Override framework defaults
Configuration File Location
Generator configuration is stored in your project's azu.yml file:
# azu.yml
generators:
# Generator-specific configurations
endpoint:
# Endpoint generator options
model:
# Model generator options
# ... other generatorsGlobal Generator Settings
Base Configuration
Generator-Specific Configuration
Endpoint Generator
Model Generator
Service Generator
Page Generator
Contract Generator
Component Generator
Middleware Generator
Environment-Specific Configuration
You can override generator settings based on the environment:
Custom Templates
Template Override
To use custom templates instead of the default ones:
Template Variables
Custom templates can use the same variables as built-in templates:
Configuration Inheritance
Generator configurations inherit from parent levels:
Global defaults (built into Azu CLI)
Project configuration (
azu.yml)Environment-specific overrides
Command-line options
Later configurations override earlier ones.
Validation
The CLI validates your generator configuration:
Examples
Minimal Configuration
Comprehensive Configuration
Best Practices
Start Simple: Begin with minimal configuration and add complexity as needed
Be Consistent: Use consistent naming and structure across your project
Environment Awareness: Use environment-specific overrides for different deployment stages
Version Control: Include your
azu.ymlin version control for team consistencyDocumentation: Document any custom configurations for team members
Testing: Test generated code to ensure configurations work as expected
Troubleshooting
Common Issues
Configuration not applied: Ensure your azu.yml is in the project root and properly formatted.
Template not found: Check that custom template paths are correct and files exist.
Validation errors: Use azu config validate to check for configuration issues.
Inheritance problems: Verify the configuration hierarchy and override order.
Debugging
Enable verbose output to see how configuration is being applied:
This will show which configuration values are being used for generation.
Last updated