BoricuaCoder.API.CoreSetup 1.0.0

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

BoricuaCoder.API.CoreSetup

A lightweight library that simplifies ASP.NET Core API setup with pre-configured JWT Bearer authentication and Swagger/OpenAPI documentation with JWT security support.

Purpose

This package eliminates boilerplate code when setting up new ASP.NET Core APIs. Instead of manually configuring JWT authentication and Swagger with security schemes, you can configure everything via appsettings.json with just two lines of code.

Features

  • JWT Bearer Authentication - Pre-configured with Authority, Audience, and HTTPS metadata settings
  • Swagger/OpenAPI - Auto-configured with JWT Bearer security scheme
  • Configuration-driven - All settings via appsettings.json
  • Minimal API friendly - Works with both Minimal APIs and Controller-based APIs

Installation

dotnet add package BoricuaCoder.API.CoreSetup

Quick Start

Step 1: Add Configuration

Add the CoreSetup section to your appsettings.json:

{
  "CoreSetup": {
    "Jwt": {
      "Authority": "https://your-identity-provider.com",
      "Audience": "your-api-audience",
      "RequireHttpsMetadata": true
    },
    "Swagger": {
      "Enabled": true,
      "Title": "My API",
      "Version": "v1",
      "RoutePrefix": "swagger"
    }
  }
}

Step 2: Configure Services

In your Program.cs, add the core setup services:

using BoricuaCoder.API.CoreSetup.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add CoreSetup (JWT + Swagger)
builder.Services.AddCoreSetup(builder.Configuration);

var app = builder.Build();

// Use CoreSetup middleware
app.UseCoreSetup();

app.MapGet("/", () => "Hello World!")
   .RequireAuthorization();

app.Run();

That's it! Your API now has:

  • JWT Bearer authentication configured
  • Swagger UI available at /swagger with JWT authorization support

Configuration Options

JwtOptions

Property Type Default Description
Authority string "" The URL of your identity provider (e.g., Auth0, IdentityServer, Keycloak)
Audience string "" The expected audience claim in the JWT token
RequireHttpsMetadata bool true Set to false for local development with HTTP identity providers

SwaggerOptions

Property Type Default Description
Enabled bool true Enable or disable Swagger UI
Title string "API" The title displayed in Swagger UI
Version string "v1" API version for the Swagger document
RoutePrefix string "swagger" URL prefix for Swagger UI (e.g., /swagger)

Environment-Specific Configuration

Use appsettings.Development.json for local development:

{
  "CoreSetup": {
    "Jwt": {
      "Authority": "http://localhost:5000",
      "Audience": "local-api",
      "RequireHttpsMetadata": false
    },
    "Swagger": {
      "Enabled": true,
      "Title": "My API (Dev)",
      "Version": "v1"
    }
  }
}

And appsettings.Production.json for production:

{
  "CoreSetup": {
    "Jwt": {
      "Authority": "https://auth.mycompany.com",
      "Audience": "production-api",
      "RequireHttpsMetadata": true
    },
    "Swagger": {
      "Enabled": false
    }
  }
}

Using the Swagger UI

  1. Run your API
  2. Navigate to https://localhost:{port}/swagger
  3. Click the Authorize button
  4. Enter your JWT token in the format: Bearer {your_token}
  5. Click Authorize to apply the token to all requests

What Gets Configured

Authentication & Authorization

  • JWT Bearer authentication scheme as default
  • Authorization services registered
  • UseAuthentication() and UseAuthorization() middleware added

Swagger/OpenAPI

  • OpenAPI document generation
  • JWT Bearer security scheme definition
  • Security requirement applied globally
  • Swagger UI with request duration display

Requirements

  • .NET 10.0 or later
  • ASP.NET Core application

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

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.1 83 1/18/2026
1.0.0 77 1/18/2026