-
Notifications
You must be signed in to change notification settings - Fork 1
Working with Configuration
This guide covers the ApiGeneratorOptions.json configuration file and the CLI commands for managing it.
The ApiGeneratorOptions.json file controls how the generator behaves. It's auto-discovered from your project directory, or you can specify it explicitly with --options.
# Create with defaults in the current directory
atc-rest-api-gen options create -o .
# Create at a specific path
atc-rest-api-gen options create -o ./config/ApiGeneratorOptions.json
# Overwrite existing file
atc-rest-api-gen options create -o . --force{
"general": {
"validateSpecificationStrategy": "Standard",
"includeDeprecated": false
},
"server": {
"namespace": null,
"subFolderStrategy": "BySegment",
"versioningStrategy": "None",
"defaultApiVersion": "1.0",
"reportApiVersions": true,
"assumeDefaultVersionWhenUnspecified": true,
"useServersBasePath": false,
"useGlobalErrorHandler": "Auto",
"useMinimalApiPackage": "Auto",
"domain": {
"generateHandlersOutput": "Handlers",
"handlerSuffix": "Handler",
"stubImplementation": "NotImplementedException"
}
},
"client": {
"namespace": null,
"generationMode": "EndpointPerOperation",
"clientSuffix": "Endpoint",
"httpClientName": null,
"generatePartialModels": false,
"generateOAuthTokenManagement": false,
"useServersBasePath": true,
"includePaths": [],
"excludePaths": []
}
}The options validate command checks your configuration file for errors and displays a summary:
# Validate options file in current directory
atc-rest-api-gen options validate -o .
# Validate a specific file
atc-rest-api-gen options validate -o ./config/ApiGeneratorOptions.json| Check | Description |
|---|---|
| π File exists | Verifies the JSON file is found at the specified path |
| π§ JSON syntax | Validates the file is well-formed JSON |
| π Known properties | Warns about unrecognized property names (typos) |
| π’ Valid enum values | Checks that strategy/mode values are valid (e.g., EndpointPerOperation, TypedClient) |
| π Namespace format | Validates namespace strings follow C# naming rules |
| π Path references | Checks that referenced paths/directories are valid |
β Validation passed - options file is valid
Configuration summary:
βββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β Section β Setting β Value β
βββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββ€
β general β validateSpecificationStrategy β Standard β
β general β includeDeprecated β False β
β server β namespace β (auto-detect) β
β server β subFolderStrategy β BySegment β
β server β versioningStrategy β None β
β server β defaultApiVersion β 1.0 β
β server.domain β generateHandlersOutput β Handlers β
β server.domain β handlerSuffix β Handler β
β server.domain β stubImplementation β NotImplementedException β
β client β namespace β (auto-detect) β
β client β generationMode β EndpointPerOperation β
β client β clientSuffix β Endpoint β
β client β generateOAuthTokenManagement β False β
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ
| Setting | Type | Default | Description |
|---|---|---|---|
validateSpecificationStrategy |
enum | Standard |
None, Minimal, Standard, Strict β how strictly to validate the OpenAPI spec |
includeDeprecated |
bool | false |
Whether to include deprecated operations and schemas |
| Setting | Type | Default | Description |
|---|---|---|---|
namespace |
string | auto | Override the generated namespace (defaults to project name) |
subFolderStrategy |
enum | BySegment |
How to organize generated files in subfolders |
versioningStrategy |
enum | None |
None, QueryString, UrlSegment, Header
|
defaultApiVersion |
string | "1.0" |
Default API version when unspecified |
reportApiVersions |
bool | true |
Include version info in response headers |
assumeDefaultVersionWhenUnspecified |
bool | true |
Use default version when client doesn't specify |
useServersBasePath |
bool | false |
Prepend base path from OpenAPI servers[0].url to routes |
useGlobalErrorHandler |
enum | Auto |
Auto, Enabled, Disabled β GlobalErrorHandlingMiddleware |
useMinimalApiPackage |
enum | Auto |
Auto, Enabled, Disabled β Atc.Rest.MinimalApi package |
| Setting | Type | Default | Description |
|---|---|---|---|
healthChecks.enabled |
bool | false |
Generate health check endpoints |
healthChecks.path |
string | "/health" |
Base path for health endpoints |
healthChecks.includeLiveness |
bool | true |
Generate /health/live liveness probe |
healthChecks.includeReadiness |
bool | true |
Generate /health/ready readiness probe |
healthChecks.security |
string | "none" |
"none" or "apiKey" (query param + header) |
healthChecks.apiKeyQueryParameterName |
string | "api-key" |
Query parameter name for API key |
healthChecks.apiKeyHeaderName |
string | "X-Health-Api-Key" |
Header name for API key |
π‘ When
security: "apiKey", the API key is read fromIConfiguration["HealthChecks:ApiKey"]at runtime. If the config value is empty, the filter passes through (no security).
β οΈ If your OpenAPI spec already defines paths under the health check base path (e.g.,/health), the generator emits aATC_API_DEP009warning about duplicate endpoint registration.
| Setting | Type | Default | Description |
|---|---|---|---|
generateHandlersOutput |
string | "Handlers" |
Directory for generated handler scaffolds |
handlerSuffix |
string | "Handler" |
Suffix for handler class names |
stubImplementation |
string | "NotImplementedException" |
Default stub: NotImplementedException or TodoComment
|
injectLogger |
bool | false |
Inject ILogger<T> constructor parameter into handler scaffolds |
injectTracing |
bool | false |
Inject ActivitySource for OpenTelemetry distributed tracing |
maxLineLength |
int | 80 |
Max line length for code formatting. Match dotnet_diagnostic.ATC201.max_line_length in .editorconfig
|
| Setting | Type | Default | Description |
|---|---|---|---|
namespace |
string | auto | Override the generated namespace |
generationMode |
enum | EndpointPerOperation |
EndpointPerOperation or TypedClient
|
clientSuffix |
string | "Endpoint" |
Suffix for client/endpoint class names |
httpClientName |
string | auto | Override the IHttpClientFactory named client |
generatePartialModels |
bool | false |
Generate partial records for extensibility |
generateOAuthTokenManagement |
bool | false |
Generate OAuth token refresh infrastructure |
useServersBasePath |
bool | true |
Prepend base path from OpenAPI servers[0].url to URLs |
includePaths |
string[] | [] |
Glob patterns to include (e.g., ["/pets/*", "/users/*"]) |
excludePaths |
string[] | [] |
Glob patterns to exclude (e.g., ["/internal/*"]) |
The generator supports two configuration approaches:
| Approach | Best For | How It Works |
|---|---|---|
Marker files (.atc-rest-api-server, etc.) |
Simple projects | JSON config embedded in the marker file, per-project |
| ApiGeneratorOptions.json | Multi-project solutions | Shared config file, referenced by marker files or auto-discovered |
Marker file settings override options file settings when both are present.
π‘ See Marker Files for the complete marker file reference.
- Marker Files β Marker file configuration reference
- Working with OpenAPI β OpenAPI specification patterns
- Working with Versioning β API versioning configuration
- Working with Security β Security scheme configuration
π Home
- πΌ FAQ Business Value
- π Getting Started with Basic
- π οΈ Getting Started with CLI
- π Migration Guide
- β¬οΈ Upgrading to v2
- π Working with OpenAPI
- π³οΈ Working with Nullability
- π οΈ Working with CLI
- π How-To Guides
- π Working with Security
- π¦ Working with Rate Limiting
- π Working with Resilience
- ποΈ Working with Caching
- π’ Working with Versioning
- β Working with Validations
- π Working with Webhooks
- βοΈ Working with Aspire
- π£οΈ Working with Endpoint Definitions
- π Working with Multi-Part Specs
- π§ͺ Working with Code Coverage
- π Working with C# Client
- π§ͺ Working with C# Client Testing
- π¦ Working with TypeScript Client
- πͺ Showcase Demo
- π§ͺ Working with E2E Testing
- βοΈ Working with Configuration
- π Marker Files
- π API Reference
- π Analyzer Rules
- β FAQ and Troubleshooting
- πΊοΈ Roadmap
- π§ Development Notes
- π¦ GitHub Repository
- π₯ NuGet Package
- π Report Issues