Project Setup Generators
These generators produce the foundational project files needed for the generated API to compile and run.
ProgramGenerator
| Scope | Single File | |—|—|
Generates the Program.cs entry point for the web API application. Includes AddNinjadog() and UseNinjadog() calls to wire up all generated services, endpoints, and middleware.
The generated Program.cs includes:
- Serilog bootstrap logger for startup error capture
- Structured logging via
UseSerilog()configured fromappsettings.json - Request correlation middleware (
RequestCorrelationMiddleware) that assigns a unique correlation ID to every request - Request logging via
UseSerilogRequestLogging()for automatic HTTP request/response logging - Try/catch/finally wrapper around the application lifecycle with
Log.CloseAndFlushAsync()to ensure logs are flushed on shutdown
IndexPageGenerator
| Scope | Single File | |—|—|
Generates a wwwroot/index.html landing page for the API. The page displays:
- Project name, version, and description from your
ninjadog.jsonconfig - Quick links to Swagger UI, the OpenAPI spec, and generated C#/TypeScript clients
- A list of all entity endpoints with their routes
The generated API serves this page at the root URL (/) using ASP.NET Core static file middleware (UseDefaultFiles + UseStaticFiles), so navigating to http://localhost:5000/ shows the landing page instead of a blank 404.
RequestCorrelationMiddlewareGenerator
| Scope | Single File | |—|—|
Generates a Middleware/RequestCorrelationMiddleware.cs that:
- Reads an incoming
X-Correlation-Idheader, or generates a new GUID if absent - Pushes the correlation ID into the Serilog
LogContextso every log entry during the request includes it - Returns the correlation ID in the
X-Correlation-Idresponse header for client-side tracing
AppSettingsGenerator
| Scope | Single File | |—|—|
Generates the appsettings.json configuration file with default settings for the application, including the SQLite connection string and Serilog structured logging configuration.
The Serilog configuration includes:
- Console sink with correlation ID in the output template
- File sink with daily rolling, 7-day retention, and correlation ID
- Enrichers for
LogContext,MachineName, andThreadId - Override levels to reduce noise from
Microsoft.AspNetCoreandSystem
DomainEntityGenerator
| Scope | Per Entity | |—|—|
Generates the domain entity class for each entity defined in ninjadog.json. Each domain entity contains all properties from the configuration as a plain C# class.