Sharkable 0.7.5

dotnet add package Sharkable --version 0.7.5
                    
NuGet\Install-Package Sharkable -Version 0.7.5
                    
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.7.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sharkable" Version="0.7.5" />
                    
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.7.5
                    
#r "nuget: Sharkable, 0.7.5"
                    
#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.7.5
                    
#: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.7.5
                    
Install as a Cake Addin
#tool nuget:?package=Sharkable&version=0.7.5
                    
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 (3)

Showing the top 3 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.

Sharkable.Testing

Testing helpers for Sharkable applications — fakes, factory wiring, and assertion utilities.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.5 37 7/18/2026
0.7.4 38 7/18/2026
0.7.3 45 7/18/2026
0.7.2 44 7/18/2026
0.6.1 75 7/15/2026
0.6.0 82 7/15/2026
0.5.7 95 7/11/2026
0.5.6 152 7/3/2026
0.5.5 153 7/2/2026
0.5.4 138 7/1/2026
0.5.3 152 6/30/2026
0.5.2 97 6/30/2026
0.5.1 108 6/29/2026
0.4.1 144 6/28/2026
0.4.0 132 6/28/2026
0.3.2 95 6/27/2026
0.3.1 149 6/27/2026
Loading failed

Plugin system: ISharkPlugin with 3 lifecycle hooks, 3 discovery paths (assembly/folder/manual), per-folder AssemblyLoadContext isolation. Framework audit fixes: AuditLogBuffer/CronScheduler disposal, unified ResponseSizeExceededException, exception handler repositioned. API consistency: ISagaExecutor interface, CronLockTtl on ICronScheduler, ConfigureJwt -> JwtOptions pattern, ConfigureAuthorization -> method, ICronJobStore default impl, sealed classes, dead code removal. Product: health checks default true, cron concurrency -> SkipIfRunning, WrapSchemaFactory startup warning. 15 features: security headers middleware, framework metrics (ISharkMetrics), IAuditSink, [SharkRateLimit]/[SharkIdempotent]/[SharkCacheProfile] attributes, request-timeout DSL, ValidationErrorMode, parallel warmup, Sharkable.Testing package, GroupConvention/EndpointConvention, OpenAPI ergonomics, IApiKeyValidator.