Dosaic.Plugins.Endpoints.RestResourceEntity 1.0.25

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dosaic.Plugins.Endpoints.RestResourceEntity --version 1.0.25                
NuGet\Install-Package Dosaic.Plugins.Endpoints.RestResourceEntity -Version 1.0.25                
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.25" />                
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.25                
#r "nuget: Dosaic.Plugins.Endpoints.RestResourceEntity, 1.0.25"                
#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.25

// Install Dosaic.Plugins.Endpoints.RestResourceEntity as a Cake Tool
#tool nuget:?package=Dosaic.Plugins.Endpoints.RestResourceEntity&version=1.0.25                

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.30 22 1/30/2025
1.0.27 4 1/29/2025
1.0.26 3 1/29/2025
1.0.25 3 1/29/2025
1.0.18 28 1/23/2025
1.0.17 25 1/23/2025