Dosaic.Plugins.Endpoints.RestResourceEntity
1.0.30
dotnet add package Dosaic.Plugins.Endpoints.RestResourceEntity --version 1.0.30
NuGet\Install-Package Dosaic.Plugins.Endpoints.RestResourceEntity -Version 1.0.30
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dosaic.Plugins.Endpoints.RestResourceEntity" Version="1.0.30" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dosaic.Plugins.Endpoints.RestResourceEntity --version 1.0.30
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dosaic.Plugins.Endpoints.RestResourceEntity, 1.0.30"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dosaic.Plugins.Endpoints.RestResourceEntity as a Cake Addin #addin nuget:?package=Dosaic.Plugins.Endpoints.RestResourceEntity&version=1.0.30 // Install Dosaic.Plugins.Endpoints.RestResourceEntity as a Cake Tool #tool nuget:?package=Dosaic.Plugins.Endpoints.RestResourceEntity&version=1.0.30
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Dosaic.Plugins.Endpoints.RestResourceEntity
Overview
A plugin that provides REST endpoint configurations for resource entities in the Dosaic framework. This plugin simplifies the creation of standardized REST endpoints for entities that implement IGuidIdentifier
.
Features
- Simplified REST endpoint configuration
- Support for standard HTTP methods
- Built-in response type management
- Configurable OpenAPI documentation
- Flexible authorization policies
- Global response handling
Installation
To install the nuget package follow these steps:
dotnet add package Dosaic.Plugins.Endpoints.RestResourceEntity
or add as package reference to your .csproj
<PackageReference Include="Dosaic.Plugins.Endpoints.RestResourceEntity" Version="" />
Usage
Configure REST endpoints for your resource entities:
public void ConfigureEndpoints(IEndpointRouteBuilder endpointRouteBuilder, IServiceProvider serviceProvider)
{
// to configure all http verbs/actions at once
endpointRouteBuilder
.AddSimpleRestResource<Entity>(serviceProvider, "api-route-resource-name")
.ForAll();
//to configure specific http verbs/actions
endpointRouteBuilder
.AddSimpleRestResource<Entity>(serviceProvider, "api-route-resource-name")
.ForDelete(c =>
c.WithDisplayName("deleter")
.WithGroupName("testgorup")
.WithOpenApiTags("test", "tester")
.WithPolicies("deleter") // or .AllowAnonymous()
.Produces<ErrorResponse>(HttpStatusCode.Accepted)
.Produces<ErrorResponse>(HttpStatusCode.OK)
.DisableDefaultResponses()
);
}
Configuration Options
- OpenAPI tags customization
- Authorization policies
- Custom response types
- Default response handling
- Anonymous access control
Global Response Types
The plugin includes default response mappings for common HTTP status codes:
- 401 Unauthorized:
ErrorResponse
- 403 Forbidden:
ErrorResponse
- 500 Internal Server Error:
ErrorResponse
- 400 Bad Request:
ValidationErrorResponse
Default response mapping can be customized
public sealed class RestResourceEntityPlugin : IPluginServiceConfiguration
{
public void ConfigureServices(IServiceCollection serviceCollection)
{
var options = new GlobalResponseOptions();
options.Add(HttpStatusCode.NoContent);
options.Add<GlobalResponseOptionsTests>(HttpStatusCode.Processing);
options.Remove(HttpStatusCode.InternalServerError);
serviceCollection.AddSingleton<GlobalResponseOptions>(options);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Dosaic.Api.OpenApi (>= 1.0.30)
- Dosaic.Hosting.Abstractions (>= 1.0.30)
- Dosaic.Plugins.Endpoints.Abstractions (>= 1.0.30)
- Dosaic.Plugins.Handlers.Cqrs (>= 1.0.30)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.