SwiftApi 8.0.0
See the version list below for details.
dotnet add package SwiftApi --version 8.0.0
NuGet\Install-Package SwiftApi -Version 8.0.0
<PackageReference Include="SwiftApi" Version="8.0.0" />
<PackageVersion Include="SwiftApi" Version="8.0.0" />
<PackageReference Include="SwiftApi" />
paket add SwiftApi --version 8.0.0
#r "nuget: SwiftApi, 8.0.0"
#:package SwiftApi@8.0.0
#addin nuget:?package=SwiftApi&version=8.0.0
#tool nuget:?package=SwiftApi&version=8.0.0
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 GETPostAction
→ HTTP POSTPutAction
→ HTTP PUTDeleteAction
→ HTTP DELETE
🛠️ Getting Started
dotnet add package SwiftApi
Basic Usage
- 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);
}
- Define your schema:
[SchemaModel]
public class User
{
public Guid Id { get; set; }
public string Name { get; set; }
[Required]
public string Email { get; set; }
}
- Register and enable SwiftApi in your
Program.cs
:
builder.Services.AddSwiftAPI(); // Register services
app.MapSwiftAPI(); // Map endpoints
- 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
- Define your Authorization Schema:
- Bearer Tokens
- Basic Auth
- API Key Headers
- 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);
}
- Update your swiftApi registration:
builder.Services.AddSwiftAPI(o =>
{
// Set the auth schema you are using, e.g., Basic, Bearer, etc.
o.AuthScheme = AuthScheme.Basic;
});
- Start your app and explore the auto-generated Swagger UI with Auth at
/swagger
.
🙋♂️ Author
Nawaf AL-Maqbali
📧 LinkedIn
Product | Versions 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. |
-
net8.0
- Microsoft.AspNetCore.OpenApi (>= 8.0.18)
- Microsoft.OpenApi (>= 1.6.24)
- Swashbuckle.AspNetCore (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.