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 generators

Global 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:

  1. Global defaults (built into Azu CLI)

  2. Project configuration (azu.yml)

  3. Environment-specific overrides

  4. Command-line options

Later configurations override earlier ones.

Validation

The CLI validates your generator configuration:

Examples

Minimal Configuration

Comprehensive Configuration

Best Practices

  1. Start Simple: Begin with minimal configuration and add complexity as needed

  2. Be Consistent: Use consistent naming and structure across your project

  3. Environment Awareness: Use environment-specific overrides for different deployment stages

  4. Version Control: Include your azu.yml in version control for team consistency

  5. Documentation: Document any custom configurations for team members

  6. 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