Sharkable 0.5.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Sharkable --version 0.5.3
                    
NuGet\Install-Package Sharkable -Version 0.5.3
                    
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="Sharkable" Version="0.5.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sharkable" Version="0.5.3" />
                    
Directory.Packages.props
<PackageReference Include="Sharkable" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sharkable --version 0.5.3
                    
#r "nuget: Sharkable, 0.5.3"
                    
#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.
#:package Sharkable@0.5.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sharkable&version=0.5.3
                    
Install as a Cake Addin
#tool nuget:?package=Sharkable&version=0.5.3
                    
Install as a Cake Tool

Sharkable

Sharkable Sharkable

A .NET 10 minimal API framework collection aimed to support AOT.

Quick Start

dotnet add package Sharkable
using Sharkable;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddShark();

var app = builder.Build();
app.UseShark();
app.Run();

For AOT mode, pass assemblies explicitly:

builder.Services.AddShark([typeof(Program).Assembly]);

Features

Auto Endpoint Discovery (New Style)

Create a class implementing ISharkEndpoint. It's automatically discovered and registered.

public class TestEndpoint : ISharkEndpoint
{
    public void AddRoutes(IEndpointRouteBuilder app)
    {
        app.MapGet("hello", () => Results.Ok("hi"));
        app.MapPost("create", (CreateRequest req) => Results.Ok(req));
    }
}

URL becomes api/test/hello, api/test/create (group name derived from class name).

Endpoint Grouping & OpenAPI Tags

Group multiple endpoints under the same URL prefix and OpenAPI tag.

[EndpointGroup("admin")]
[SharkTag("admin")]
public class UserEndpoint : ISharkEndpoint
{
    public void AddRoutes(IEndpointRouteBuilder app)
    {
        app.MapGet("users", () => Results.Ok(users));
    }
}

[EndpointGroup("admin")]
[SharkTag("admin")]
public class RoleEndpoint : ISharkEndpoint
{
    public void AddRoutes(IEndpointRouteBuilder app)
    {
        app.MapGet("roles", () => Results.Ok(roles));
    }
}

Both under api/admin/users and api/admin/roles, sharing OpenAPI tag admin. OperationIds are auto-generated via {group}_{httpMethod}_{path}.

Auto DI Registration

Mark classes with attributes or marker interfaces for auto-registration.

[ScopedService]   // or [SingletonService], [TransientService]
public class Monitor : IMonitor
{
    public void Show() { }
}

// Or use marker interfaces:
public class Monitor : IMonitor, IScoped { }

Global Exception Handler

Converts unhandled exceptions to UnifiedResult<T> JSON responses automatically.

app.UseShark(opt =>
{
    opt.ExceptionHandlerOptions.Map<MyException>(HttpStatusCode.Forbidden);
});

Unified Response

Consistent API response format across all endpoints.

return data.AsOkResult();
return "error".AsBadRequest();
return "no access".AsUnauthorized();

// Or with auto-wrap:
app.UseShark(opt => opt.EnableAutoWrap = true);
app.MapGet("hello", () => "world"); // -> { "statusCode": 200, "data": "world", ... }

FluentValidation Integration

Automatic request validation with FluentValidation.

builder.Services.AddShark(opt => opt.EnableValidation = true);

public class CreateUserValidator : AbstractValidator<CreateUserRequest>
{
    public CreateUserValidator()
    {
        RuleFor(x => x.Email).NotEmpty().EmailAddress();
    }
}

Invalid requests return 400 with a UnifiedResult error body.

OpenAPI & Scalar UI

OpenAPI spec at /openapi/v1.json, Scalar UI at /scalar/v1. Enabled by default.

builder.Services.AddShark(opt =>
{
    opt.ConfigureOpenApi(options => { /* configure OpenAPI options */ });
});

Idempotency Middleware

Opt-in middleware that lets clients safely retry unsafe HTTP requests. When a client sends the Idempotency-Key header on a POST / PUT / PATCH / DELETE request, the first response is cached; subsequent requests with the same key replay it. Reusing a key with a different payload returns 422; concurrent same-key requests return 409 with Retry-After: 1.

builder.Services.AddShark(opt =>
{
    opt.EnableIdempotency = true;
    opt.ConfigureIdempotency(o =>
    {
        o.Ttl = TimeSpan.FromHours(24);  // default
        o.MaxResponseSize = 1_048_576;   // default 1 MiB
    });
});

AutoCrud (SqlSugar)

Auto-generate CRUD endpoints with SqlSugar.

builder.Services.AddShark(opt =>
{
    opt.ConfigureAutoCrud(sqlSugar => { /* configure SqlSugar */ });
});

Endpoint Format

Configure URL naming conventions globally.

builder.Services.AddShark(opt =>
{
    opt.Format = EndpointFormat.SnakeCase; // CamelCase, ToLower, UnChanged
    opt.ApiPrefix = "api"; // default
});

AOT Support

Sharkable is designed for AOT compilation. Pass assemblies explicitly and register JsonSerializerContext:

builder.Services.AddShark([typeof(Program).Assembly]);

Old-style [SharkEndpoint] + [SharkMethod] endpoints use reflection and will NOT work in AOT mode.

Documentation

Full documentation: https://sharkableio.github.io

License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Sharkable:

Package Downloads
Sharkable.AutoCrud.SqlSugar

AutoCrud SqlSugar plugin for Sharkable — automatic CRUD API generation with health check

Sharkable.Cache.Redis

Redis-backed distributed stores for Sharkable — idempotency and rate limiting.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.7 31 7/11/2026
0.5.6 149 7/3/2026
0.5.5 153 7/2/2026
0.5.4 136 7/1/2026
0.5.3 149 6/30/2026
0.5.2 94 6/30/2026
0.5.1 106 6/29/2026
0.4.1 143 6/28/2026
0.4.0 131 6/28/2026
0.3.2 93 6/27/2026
0.3.1 147 6/27/2026
0.2.0 109 6/8/2026
0.1.0 108 6/8/2026
0.0.24 284 10/2/2024
0.0.23 254 9/27/2024
0.0.21 218 9/25/2024
0.0.20 212 9/24/2024
Loading failed