SwiftApi 8.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SwiftApi --version 8.0.0
                    
NuGet\Install-Package SwiftApi -Version 8.0.0
                    
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="SwiftApi" Version="8.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SwiftApi" Version="8.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SwiftApi" />
                    
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 SwiftApi --version 8.0.0
                    
#r "nuget: SwiftApi, 8.0.0"
                    
#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 SwiftApi@8.0.0
                    
#: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=SwiftApi&version=8.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SwiftApi&version=8.0.0
                    
Install as a Cake Tool

SwiftApi

SwiftApi is a powerful .NET class library that transforms your interfaces into fully functional API endpoints — with zero controller boilerplate. Designed for speed, simplicity, and flexibility, SwiftApi enables you to build scalable APIs with minimal code and maximum control.


🚀 Key Features

  • Zero Controllers
    Automatically exposes your service interfaces as API endpoints — no need to write a single controller.

  • ⚙️ Unlimited Endpoints
    Add as many interfaces and methods as you like — SwiftApi handles the routing dynamically.

  • 🔐 Built-in Security
    Easily secure endpoints with support for various authentication schemes (Bearer, Basic, API Key, etc.).

  • 📄 Swagger Support
    Built-in Swagger/OpenAPI integration for instant, interactive API documentation.

  • 🧩 Endpoint Management
    Enable, disable, or configure individual endpoints via attributes or settings — without touching controllers.

  • 🎯 .NET 8+ Compatible
    Built on the latest .NET standards with full support for .NET 8 and future versions.


✅ Supported Actions

SwiftApi currently supports the following HTTP actions via method attributes:

  • GetAction → HTTP GET
  • PostAction → HTTP POST
  • PutAction → HTTP PUT
  • DeleteAction → HTTP DELETE

🛠️ Getting Started

dotnet add package SwiftApi

Basic Usage

  1. Define your interface:
[EndPoint("users")]
public interface IUserService
{
    [GetAction]
    Task<User?> GetUserByIdAsync([QueryParam] Guid id);
    [GetAction("get-users")]
    Task<List<User>> GetUsersAsync();
    [PostAction("create-users")]
    Task CreateUserAsync([BodyParam] User user);
    [PutAction("update-users")]
    Task UpdateUserAsync([RouteParam] Guid id, [BodyParam] User user);
    [DeleteAction("delete-users")]
    Task DeleteUserAsync([RouteParam] Guid id);
}
  1. Define your schema:
[SchemaModel]
public class User
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    [Required]
    public string Email { get; set; }
}
  1. Register and enable SwiftApi in your Program.cs:
builder.Services.AddSwiftAPI(); // Register services
app.MapSwiftAPI();              // Map endpoints
  1. Start your app and explore the auto-generated Swagger UI at /swagger.

🔐 Securing Endpoints

Use attributes or configuration to require authentication per endpoint or globally. SwiftApi supports:

  • Bearer Tokens
  • Basic Auth
  • API Key Headers

Implementing Authorization & Authentication

  1. Define your Authorization Schema:
  • Bearer Tokens
  • Basic Auth
  • API Key Headers
  1. Add Authorization and Authentication to you interface
[EndPoint("users")]
[SecureEndpoint(role: "Admin,Manager", policy: "read,write,edit,delete")]
public interface IUserService
{
    [GetAction("get-user-by-id")]
    Task<User?> GetUserByIdAsync([QueryParam] Guid id);
    [GetAction("get-users")]
    [OpenAction] //Allows unauthenticated access
    Task<List<User>> GetUsersAsync();
    [PostAction("create-users")]
    Task CreateUserAsync([BodyParam] User user);
    [PutAction("update-users")]
    Task UpdateUserAsync([RouteParam] Guid id, [BodyParam] User user);
    [DeleteAction("delete-users")]
    Task DeleteUserAsync([RouteParam] Guid id);
}
  1. Update your swiftApi registration:
builder.Services.AddSwiftAPI(o =>
{
    // Set the auth schema you are using, e.g., Basic, Bearer, etc.
    o.AuthScheme = AuthScheme.Basic; 
});
  1. Start your app and explore the auto-generated Swagger UI with Auth at /swagger.

🙋‍♂️ Author

Nawaf AL-Maqbali
📧 LinkedIn

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.  net10.0 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.