Encamina.Enmarcha.AspNet.OpenApi 8.1.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package Encamina.Enmarcha.AspNet.OpenApi --version 8.1.7                
NuGet\Install-Package Encamina.Enmarcha.AspNet.OpenApi -Version 8.1.7                
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="Encamina.Enmarcha.AspNet.OpenApi" Version="8.1.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Encamina.Enmarcha.AspNet.OpenApi --version 8.1.7                
#r "nuget: Encamina.Enmarcha.AspNet.OpenApi, 8.1.7"                
#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.
// Install Encamina.Enmarcha.AspNet.OpenApi as a Cake Addin
#addin nuget:?package=Encamina.Enmarcha.AspNet.OpenApi&version=8.1.7

// Install Encamina.Enmarcha.AspNet.OpenApi as a Cake Tool
#tool nuget:?package=Encamina.Enmarcha.AspNet.OpenApi&version=8.1.7                

OpenApi

Nuget package

This package provides extensions and types to work with OpenAPI (a.k.a. Swagger).

Setup

Nuget package

First, install NuGet. Then, install Encamina.Enmarcha.AspNet.OpenApi from the package manager console:

PM> Install-Package Encamina.Enmarcha.AspNet.OpenApi

.NET CLI:

First, install .NET CLI. Then, install Encamina.Enmarcha.AspNet.OpenApi from the .NET CLI:

dotnet add package Encamina.Enmarcha.AspNet.OpenApi

How to use

Middlewares

GroupNameKeyAuthorizationMiddleware

This middleware is used to block access to an OpenAPI document or specification by using a pre-shared key that must be provided in the request header per specification.

To configure, use the GroupNameKeyAuthenticationOptions class.

When requesting an OpenAPI specification, identified by its group name, the client must provide the pre-shared key in the request header. Otherwise, the request will fail with an HTTP 401 UNAUTHORIZED response.

Extensions

IApplicationBuilderExtensions

The IApplicationBuilderExtensions is a static class that provides extension methods for IApplicationBuilder, usually to add and configure middlewares.

Using it is quite simple, just get an instance of an IApplicationBuilder and call any of the available extension methods.


var builder = WebApplication.CreateBuilder(new WebApplicationOptions()
{
    ContentRootPath = Directory.GetCurrentDirectory(),
});

// ...

var app = builder.Build();

app.UseSwaggerGroupNameKeyAuthorization(options =>
{
    // Enable only if not in Development environment. Allow developers to test without keys...
    options.IsEnabled = !builder.Environment.IsDevelopment(); 
});

// ...

Currently, available extension methods are:

  • UseSwaggerGroupNameKeyAuthorization(this IApplicationBuilder app, SwaggerGroupNameKeyAuthenticationOptions options): adds the GroupNameKeyAuthorizationMiddleware middleware using provided options.
  • UseSwaggerGroupNameKeyAuthorization(this IApplicationBuilder app, Action<SwaggerGroupNameKeyAuthenticationOptions>? setupAction = null): adds the GroupNameKeyAuthorizationMiddleware middleware configuring options inline.

Important: Make sure that UseSwaggerGroupNameKeyAuthorization is added before any UseSwagger(), UseSwaggerUI(), or any other OpenAPI implementation middleware call, so that authorization middleware is called before accessing the OpenAPI document.

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. 
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
8.2.0 266 10/22/2024
8.2.0-preview-01-m01 105 9/17/2024
8.1.9-preview-03 55 11/19/2024
8.1.9-preview-02 56 10/22/2024
8.1.9-preview-01 322 10/4/2024
8.1.8 264 9/23/2024
8.1.8-preview-07 270 9/12/2024
8.1.8-preview-06 251 9/11/2024
8.1.8-preview-05 85 9/10/2024
8.1.8-preview-04 419 8/16/2024
8.1.8-preview-03 196 8/13/2024
8.1.8-preview-02 103 8/13/2024
8.1.8-preview-01 116 8/12/2024
8.1.7 109 8/7/2024
8.1.7-preview-09 182 7/3/2024
8.1.7-preview-08 90 7/2/2024
8.1.7-preview-07 81 6/10/2024
8.1.7-preview-06 81 6/10/2024
8.1.7-preview-05 76 6/6/2024
8.1.7-preview-04 88 6/6/2024
8.1.7-preview-03 98 5/24/2024
8.1.7-preview-02 71 5/10/2024
8.1.7-preview-01 72 5/8/2024
8.1.6 139 5/7/2024
8.1.6-preview-08 62 5/2/2024
8.1.6-preview-07 90 4/29/2024
8.1.6-preview-06 588 4/26/2024
8.1.6-preview-05 100 4/24/2024
8.1.6-preview-04 119 4/22/2024
8.1.6-preview-03 91 4/22/2024
8.1.6-preview-02 159 4/17/2024
8.1.6-preview-01 90 4/15/2024
8.1.5 122 4/15/2024
8.1.5-preview-15 93 4/10/2024
8.1.5-preview-14 73 3/20/2024
8.1.5-preview-13 77 3/18/2024
8.1.5-preview-12 99 3/13/2024
8.1.5-preview-11 85 3/13/2024
8.1.5-preview-10 89 3/13/2024
8.1.5-preview-09 88 3/12/2024
8.1.5-preview-08 80 3/12/2024
8.1.5-preview-07 101 3/8/2024
8.1.5-preview-06 343 3/8/2024
8.1.5-preview-05 84 3/7/2024
8.1.5-preview-04 83 3/7/2024
8.1.5-preview-03 87 3/7/2024
8.1.5-preview-02 192 2/28/2024
8.1.5-preview-01 171 2/19/2024
8.1.4 262 2/15/2024
8.1.3 138 2/13/2024
8.1.3-preview-07 87 2/13/2024