Presentations : MinimalApi
The Presentation MinimalApi layer templates generate a complete ASP.NET Core Minimal API project for each bounded context. The generator produces the project file, assembly reference marker, application configuration, dependency injection setup, global usings, program entry point, launch settings, endpoint tags, and a full set of REST endpoints for each entity — including create, edit, delete commands and list, details, get-edit, get-delete queries — all driven by the entity and bounded context definitions configured in the Scaffolder.net UI. This layer serves as the backend API consumed by the BlazorWebAssembly frontend or any other HTTP client.
Project File
The {{Solution.Name}}.Presentation.MinimalApi.{{BoundedContext.Name}}.csproj file defines the Minimal API web project using the Microsoft.NET.Sdk.Web SDK. It includes project references to the Infrastructure.Persistence project (which transitively brings in the Application and Domain projects) and the Shared.Presentation and Shared.Presentation.MinimalApi projects, providing access to shared presentation abstractions, endpoint interfaces, and MinimalApi-specific extensions.
Assembly Reference
The {{Solution.Name}}PresentationMinimalApi{{BoundedContext.Name}}AssemblyReference class is an internal sealed marker class used to reference the MinimalApi assembly for reflection-based endpoint discovery and service registration scanning.
Appsettings
- appsettings.json : Configures the CORS allowed origins, the default and supported localization cultures, and Serilog sinks (Console and File with structured JSON and readable text formats) with enrichment from log context, environment name, machine name, and thread ID. Logging minimum levels are set to
Warningfor the production environment. - appsettings.Development.json : Overrides the CORS allowed origins to
https://localhost:7200(matching the BlazorWebAssembly development URL) and Serilog minimum levels toInformationfor the Development environment, providing more verbose logging during development.
Global Usings
The GlobalUsings.cs file declares global using directives for the Minimal API project. It includes standard .NET namespaces, Microsoft ASP.NET Core Builder, HTTP, MVC, Routing, and dependency injection namespaces, and Serilog. The generator dynamically appends global usings for each entity's Application layer namespaces (commands, queries, services) via {PresentationMinimalApiGenerator.GetGlobalUsings}, ordered alphabetically by entity name, followed by Application and Domain resource namespaces, Infrastructure.Persistence dependency injection, and the MinimalApi presentation namespaces including the Tags namespace. Shared namespaces for ProblemDetails DTOs, presentation MinimalApi abstractions, and result extensions are also included.
Program
The Program.cs file contains the application entry point. It creates the WebApplicationBuilder, calls ConfigureWebApplicationBuilder to register all services, builds the WebApplication, logs startup information using Serilog, calls ConfigureWebApplication to set up the middleware pipeline and endpoint routing, and runs the application. A global try-catch-finally block ensures fatal exceptions are logged and the logger is properly flushed on shutdown.
Dependency Injection
DependencyInjection directory contains two extension classes that configure the Minimal API application :
- WebApplicationBuilderExtension : A static class with a
ConfigureWebApplicationBuildermethod that registers Serilog, localization, Application services, Infrastructure.Persistence services, MinimalApi infrastructure, and discovers all endpoint classes via reflection using the{{Solution.Name}}PresentationMinimalApi{{BoundedContext.Name}}AssemblyReferenceassembly. - WebApplicationExtension : A static class with a
ConfigureWebApplicationmethod that configures exception handling, MinimalApi middleware, Serilog request logging, request localization based on theAccept-Languageheader, FluentValidation display name resolution (using the Application and Domain resource types), and endpoint routing.
Features
Features directory contains the endpoint classes that define the REST API routes for each entity, organized into Commands and Queries subdirectories.
Features : Entity Commands
For each entity, the generator produces a {{Entity.NameSingular}}CommandEndpoints sealed class implementing IEndpoint. The class defines three REST endpoints in the /{{Entity.NamePlural}} route group, all tagged with Tag.{{Entity.NameSingular}}Commands :
- POST /{{Entity.NamePlural}}/Create : Accepts a
Create{{Entity.NameSingular}}CommandRequestfrom the request body, calls the command service to create the entity, returns201 Createdwith theCreate{{Entity.NameSingular}}CommandResponse(including the Id and all property values generated by{PresentationMinimalApiGenerator.GetInlinePropertiesName.WithId.ForCreate}) and aLocationheader, or400 Bad Requestwith aProblemDetailsDtoon failure. - PUT /{{Entity.NamePlural}}/Edit : Accepts an
Edit{{Entity.NameSingular}}CommandRequestfrom the request body, calls the command service to edit the entity, returns200 OKwith theEdit{{Entity.NameSingular}}CommandResponse, or400 Bad Request/404 Not Foundwith aProblemDetailsDtoon failure. - DELETE /{{Entity.NamePlural}}/Delete : Accepts a
Delete{{Entity.NameSingular}}CommandRequestfrom the request body, calls the command service to delete the entity, returns200 OKwith theDelete{{Entity.NameSingular}}CommandResponse, or404 Not Foundwith aProblemDetailsDtoon failure.
Features : Entity Queries
For each entity, the generator produces a {{Entity.NameSingular}}QueryEndpoints sealed class implementing IEndpoint. The class defines four REST GET endpoints in the /{{Entity.NamePlural}} route group, all tagged with Tag.{{Entity.NameSingular}}Queries :
- GET /{{Entity.NamePlural}} : Calls the query service to retrieve all entities, returns
200 OKwith a list ofGet{{Entity.NameSingular}}ListQueryResponse. - GET /{{Entity.NamePlural}}/{{{{Entity.NameSingular.Camelize}}Id}} : Calls the query service to retrieve entity details by Id, returns
200 OKwith aGet{{Entity.NameSingular}}DetailsQueryResponse, or404 Not Foundwith aProblemDetailsDtoon failure. - GET /{{Entity.NamePlural}}/{{{{Entity.NameSingular.Camelize}}Id}}/GetEdit : Calls the query service to retrieve the edit data for an entity by Id, returns
200 OKwith anEdit{{Entity.NameSingular}}CommandRequestpre-populated with current values, or404 Not Foundon failure. - GET /{{Entity.NamePlural}}/{{{{Entity.NameSingular.Camelize}}Id}}/GetDelete : Calls the query service to retrieve the delete confirmation data for an entity by Id, returns
200 OKwith aDelete{{Entity.NameSingular}}CommandRequestpre-populated with current values, or404 Not Foundon failure.
Properties
The launchSettings.json file defines the HTTPS launch profile for the development environment, with the application URL set to https://localhost:7300, ASPNETCORE_ENVIRONMENT set to Development, the browser launch option enabled, and the launch URL set to scalar for accessing the Scalar API documentation interface.
Tags
The Tag.cs file defines a static Tag class containing string constants used to group API endpoints by entity in the generated API documentation (e.g., Scalar). The generator populates this class with two constants per entity via {PresentationMinimalApiGenerator.GetTags} : {{Entity.NameSingular}}Commands (for create, edit, delete endpoints) and {{Entity.NameSingular}}Queries (for list, details, get-edit, get-delete endpoints), ordered alphabetically by entity name.