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

The generator produces two application configuration files :
  • 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 Warning for the production environment.
  • appsettings.Development.json : Overrides the CORS allowed origins to https://localhost:7200 (matching the BlazorWebAssembly development URL) and Serilog minimum levels to Information for 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

The DependencyInjection directory contains two extension classes that configure the Minimal API application :
  • WebApplicationBuilderExtension : A static class with a ConfigureWebApplicationBuilder method 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}}AssemblyReference assembly.
  • WebApplicationExtension : A static class with a ConfigureWebApplication method that configures exception handling, MinimalApi middleware, Serilog request logging, request localization based on the Accept-Language header, FluentValidation display name resolution (using the Application and Domain resource types), and endpoint routing.

Features

The 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}}CommandRequest from the request body, calls the command service to create the entity, returns 201 Created with the Create{{Entity.NameSingular}}CommandResponse (including the Id and all property values generated by {PresentationMinimalApiGenerator.GetInlinePropertiesName.WithId.ForCreate}) and a Location header, or 400 Bad Request with a ProblemDetailsDto on failure.
  • PUT /{{Entity.NamePlural}}/Edit : Accepts an Edit{{Entity.NameSingular}}CommandRequest from the request body, calls the command service to edit the entity, returns 200 OK with the Edit{{Entity.NameSingular}}CommandResponse, or 400 Bad Request / 404 Not Found with a ProblemDetailsDto on failure.
  • DELETE /{{Entity.NamePlural}}/Delete : Accepts a Delete{{Entity.NameSingular}}CommandRequest from the request body, calls the command service to delete the entity, returns 200 OK with the Delete{{Entity.NameSingular}}CommandResponse, or 404 Not Found with a ProblemDetailsDto on 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 OK with a list of Get{{Entity.NameSingular}}ListQueryResponse.
  • GET /{{Entity.NamePlural}}/{{{{Entity.NameSingular.Camelize}}Id}} : Calls the query service to retrieve entity details by Id, returns 200 OK with a Get{{Entity.NameSingular}}DetailsQueryResponse, or 404 Not Found with a ProblemDetailsDto on 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 OK with an Edit{{Entity.NameSingular}}CommandRequest pre-populated with current values, or 404 Not Found on 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 OK with a Delete{{Entity.NameSingular}}CommandRequest pre-populated with current values, or 404 Not Found on 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.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.