BIAB.WebAPI 0.1.1

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

Box in a Box Web API Library

Adds a extensions for .Net 6 and .Net 7 Web APIs to more easily configure Authentication, Authorization, and CORS.

Getting Started

Installation

Option 1: From Source
  1. Get a copy of a Release DLL.
  2. Open your project in Visual Studio.
  3. Right click on your project and select "Add Reference".
  4. Select "Browse" and navigate to the DLL.
  5. Select the DLL and click "Add".
  6. Click "OK" to close the "Add Reference" dialog.
Option 2: From NuGet
  1. Open your project in Visual Studio.
  2. Right click on your project and select "Manage NuGet Packages".
  3. Select "Browse" and search for "BIAB.WebAPI".
  4. Select the package and click "Install".

Usage

Here is an Example Program.cs file that uses the library. Please note that the DbContext needs to be replaced with one from your project.

using BIAB.WebAPI;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Get the Settings
ApiSettings settings = builder.AddSettings<ApiSettings>();

// Basic WebApi Steps
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

// Add Swagger Options for Swagger Generation
builder.Services.AddSwaggerGen(c =>
{
    c.AddSwaggerJwtBearer(); // Adds the JWT Bearer authentication scheme to the Swagger UI.
});

// Add the DbContext
builder.Services.AddDbContext<IdentityDbContext>(options =>
    options.UseSqlite(settings.DbConnectionString));

// For Identity
builder.Services.AddBasicIdentity<IdentityUser, IdentityRole, IdentityDbContext>();

// Adding Authentication
builder.Services.AddJwtAuthentication(settings);

// Build the WebApp
var app = builder.Build();

// Development Only - Enables Swagger UI and Disable CORS
app.DevelopmentCorsAndSwaggerOverride();

// Adds Https Redirection
app.UseHttpsRedirection();

// Adds Authentication
app.UseJwtAuthentication();

// Basic WebApi Steps
app.MapControllers();

// Run Migrations Automatically for EF Core DbContexts
app.AutoMigrateDb<IdentityDbContext>();

// Run the App
app.Run();

Example Settings

using BIAB.WebAPI;

public class CustomSettings : ApiSettings
{
    public string ImportantSetting => Configuration?["ImportantSetting"] ?? "Default Value";
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.

Version Downloads Last Updated
0.3.2-beta 156 4/29/2024
0.3.1 204 4/7/2024
0.3.0 163 4/7/2024
0.2.0 344 10/17/2023
0.1.3 182 10/17/2023
0.1.2 207 10/8/2023
0.1.1 343 1/24/2023
0.1.0 320 1/24/2023