Despro.Framework.Presentation.Api
2.1.1
dotnet add package Despro.Framework.Presentation.Api --version 2.1.1
NuGet\Install-Package Despro.Framework.Presentation.Api -Version 2.1.1
<PackageReference Include="Despro.Framework.Presentation.Api" Version="2.1.1" />
<PackageVersion Include="Despro.Framework.Presentation.Api" Version="2.1.1" />
<PackageReference Include="Despro.Framework.Presentation.Api" />
paket add Despro.Framework.Presentation.Api --version 2.1.1
#r "nuget: Despro.Framework.Presentation.Api, 2.1.1"
#:package Despro.Framework.Presentation.Api@2.1.1
#addin nuget:?package=Despro.Framework.Presentation.Api&version=2.1.1
#tool nuget:?package=Despro.Framework.Presentation.Api&version=2.1.1
Despro.Framework.Presentation.Api
The controller-based presentation flavor of Despro Framework.
Despro.Framework.Presentation.Api specializes
Despro.Framework.Presentation for
controller-based Web APIs. It provides a base ApiController that turns domain
OperationResult/OperationQueryResult values into the standardized ApiResult envelope,
plus a route-prefix convention and Newtonsoft-based JSON configuration.
- Package:
Despro.Framework.Presentation.Api - Version:
2.0.8 - Target framework:
net10.0 - Depends on:
Despro.Framework.Presentation
Installation
dotnet add package Despro.Framework.Presentation.Api
Setup
using Despro.Framework.Presentation;
using Despro.Framework.Presentation.Api;
// shared presentation services (JWT, Swagger, CORS, Mapster, HSTS)
builder.Services.AddFrameworkPresentationWeb(builder.Configuration, "My Application", "DefaultCorsPolicy");
// controller-based services
builder.Services.AddFrameworkPresentationWebApi(RoutePrefix: "v{version:apiVersion}/[controller]");
var app = builder.Build();
app.UseFrameworkPresentationWeb(ShowSwaggerInProduction: false);
app.UseFrameworkPresentationWebApi(); // maps controllers
app.Run();
AddFrameworkPresentationWebApi configures controllers with a RoutePrefixConvention,
Newtonsoft JSON (DefaultContractResolver, null naming policy) and converts invalid
ModelState into a thrown exception (handled by the shared exception middleware).
UseFrameworkPresentationWebApi calls MapControllers().
Key components
ApiController (ControllerTools)
An [ApiController] / [ApiVersion(1.0)] base ControllerBase with helpers that build an
ApiResult, set the HTTP status code from the mapped AppStatusCode, and cover the command
and query cases:
| Method | Input → Output |
|---|---|
CommandResult(OperationResult) |
command with no payload |
CommandResult<TData>(OperationResult<TData>) |
command with payload |
QueryResult<TData>(TData) |
raw query result (always success) |
QueryResult<TData>(OperationQueryResult<TData>) |
query with status |
RoutePrefixConvention (Utilites)
An IApplicationModelConvention that applies the configured route prefix
(e.g. v{version:apiVersion}/[controller]) to every [ApiController].
Usage
public class ProductsController(ISender sender) : ApiController
{
[HttpPost]
public async Task<ApiResult<long?>> Create(CreateProductCommand command)
=> CommandResult(await sender.Send(command));
[HttpGet]
public async Task<ApiResult<GridData<ProductDto>>> List([FromQuery] string grid)
{
var baseGrid = new BaseGrid();
baseGrid.Set(grid); // hydrate paging/filtering from the JSON query string
return QueryResult(await sender.Send(new ProductGridQuery(baseGrid)));
}
}
Every response is a consistent ApiResult with the correct HTTP status code.
Project structure
Despro.Framework.Presentation.Api
├── ControllerTools/ # ApiController base
├── Utilites/ # RoutePrefixConvention
├── FrameworkPresentationWebDi.cs # AddFrameworkPresentationWebApi
└── FrameworkPresentationWebUseApp.cs # UseFrameworkPresentationWebApi
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Despro.Framework.Presentation (>= 2.10.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.