Acontplus.ApiDocumentation 1.2.0

dotnet add package Acontplus.ApiDocumentation --version 1.2.0
                    
NuGet\Install-Package Acontplus.ApiDocumentation -Version 1.2.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="Acontplus.ApiDocumentation" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Acontplus.ApiDocumentation" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Acontplus.ApiDocumentation" />
                    
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 Acontplus.ApiDocumentation --version 1.2.0
                    
#r "nuget: Acontplus.ApiDocumentation, 1.2.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 Acontplus.ApiDocumentation@1.2.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=Acontplus.ApiDocumentation&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Acontplus.ApiDocumentation&version=1.2.0
                    
Install as a Cake Tool

Acontplus.ApiDocumentation

NuGet .NET License

Standardized API versioning and Swagger/OpenAPI documentation for ASP.NET Core. Works with controller-based APIs, Minimal APIs, and mixed projects — including correct multi-version Swagger UI dropdown support.


🚀 Features

  • Full Minimal API versioningapp.NewApiVersionSet() + WithApiVersionSet() supported out of the box
  • Swagger UI version dropdown — all registered versions appear correctly via app.DescribeApiVersions()
  • Per-endpoint version control — assign individual endpoints to V1-only, V2-only, or all versions
  • Controller-based API versioning[ApiVersion] attribute support via AddMvc() integration
  • JWT Bearer Auth UI — pre-configured Bearer token auth in Swagger UI
  • XML Comments — auto-included from all assemblies in the output directory
  • Custom metadata — contact, license, and description from appsettings.json
  • .NET 10+ ready

📦 Installation

dotnet add package Acontplus.ApiDocumentation

Also enable XML documentation in your .csproj:

<GenerateDocumentationFile>true</GenerateDocumentationFile>

⚙️ Configuration (appsettings.json)

"SwaggerInfo": {
  "ContactName": "Your Team",
  "ContactEmail": "support@example.com",
  "ContactUrl": "https://example.com/support",
  "LicenseName": "MIT License",
  "LicenseUrl": "https://opensource.org/licenses/MIT"
}

🎯 Quick Start — Controller-based API

using Acontplus.ApiDocumentation;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddApiVersioningAndDocumentation(); // registers versioning + SwaggerGen

var app = builder.Build();

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();

// Call AFTER MapControllers so all endpoint metadata is registered
if (app.Environment.IsDevelopment())
    app.UseApiVersioningAndDocumentation();

app.Run();

Version your controllers with [ApiVersion]:

[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiVersion("2.0")]
public class ProductsController : ControllerBase
{
    [HttpGet]
    [MapToApiVersion("1.0")]
    public IActionResult GetV1() => Ok("V1 response");

    [HttpGet]
    [MapToApiVersion("2.0")]
    public IActionResult GetV2() => Ok("V2 response");
}

🎯 Quick Start — Minimal API

Important: UseApiVersioningAndDocumentation() must be called after all app.MapXxx() calls. This is because the WebApplication overload uses app.DescribeApiVersions() which scans live endpoint data sources — calling it before endpoints are mapped yields an incomplete dropdown.

using Acontplus.ApiDocumentation;
using Asp.Versioning;
using Asp.Versioning.Builder;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApiVersioningAndDocumentation(); // registers versioning + SwaggerGen

var app = builder.Build();

// 1. Build a shared version set
ApiVersionSet versionSet = app.NewApiVersionSet()
    .HasApiVersion(new ApiVersion(1, 0))
    .HasApiVersion(new ApiVersion(2, 0))
    .ReportApiVersions()
    .Build();

// 2. Assign endpoints to specific versions
var v1 = app.MapGroup("").WithApiVersionSet(versionSet).MapToApiVersion(1, 0);
var v2 = app.MapGroup("").WithApiVersionSet(versionSet).MapToApiVersion(2, 0);
var all = app.MapGroup("")
    .WithApiVersionSet(versionSet)
    .HasApiVersion(new ApiVersion(1, 0))
    .HasApiVersion(new ApiVersion(2, 0));

v1.MapGet("/barcode", () => "Barcode V1").WithTags("Barcode");
v2.MapGet("/storage", () => "Storage V2").WithTags("Storage");
all.MapGet("/products", () => "Products V1+V2").WithTags("Products");

// 3. Call LAST — after all Map* calls
if (app.Environment.IsDevelopment())
    app.UseApiVersioningAndDocumentation(); // WebApplication overload: uses DescribeApiVersions()

app.Run();

🗂️ Per-Endpoint Version Control

Use three groups sharing the same ApiVersionSet to control exactly which Swagger definition each endpoint appears in:

Group How to declare Swagger shows in
V1 only .WithApiVersionSet(vs).MapToApiVersion(1, 0) V1 definition only
V2 only .WithApiVersionSet(vs).MapToApiVersion(2, 0) V2 definition only
Both .WithApiVersionSet(vs).HasApiVersion(1,0).HasApiVersion(2,0) V1 and V2 definitions

🔄 UseApiVersioningAndDocumentation overloads

The library provides two overloads:

WebApplication overload (Minimal APIs & mixed projects — preferred)

app.UseApiVersioningAndDocumentation(); // app is WebApplication

Uses app.DescribeApiVersions() internally — scans live endpoint data sources at call time. Always reflects every version set registered via app.NewApiVersionSet(). Must be called after all app.MapXxx().

IApplicationBuilder overload (controller-only projects)

IApplicationBuilder appBuilder = app;
appBuilder.UseApiVersioningAndDocumentation();

Uses IApiVersionDescriptionProvider (cached singleton). Safe for controller-only APIs since controller versions are registered at DI build time, before the pipeline runs. Includes a safe V1 fallback if no versions are discovered.


🛠️ What AddApiVersioningAndDocumentation registers

Registration Purpose
AddApiVersioning(...) Core versioning: default V1, URL segment + header + media type readers
.AddMvc() Controller [ApiVersion] attribute support
.AddApiExplorer(GroupNameFormat="'v'V") IApiVersionDescriptionProvider for both controllers and Minimal APIs
ConfigureOptions<ConfigureSwaggerOptions> Creates one Swagger doc per discovered version using appsettings.json metadata
AddSwaggerGen(...) Swagger generator with JWT Bearer auth and auto XML comments

📄 License & Info


Built with ❤️ for the .NET community


© 2025 Acontplus All rights reserved.

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.2.0 52 3/1/2026
1.1.3 98 2/22/2026
1.1.2 120 1/1/2026
1.1.1 195 12/23/2025
1.1.0 221 11/23/2025
1.0.6 215 10/23/2025
1.0.5 226 9/3/2025
1.0.4 145 7/11/2025
1.0.3 128 7/11/2025
1.0.2 174 7/9/2025
1.0.1 195 6/30/2025
1.0.0 182 6/30/2025

v1.2.0: Added WebApplication overload for UseApiVersioningAndDocumentation
     that uses app.DescribeApiVersions() to read live endpoint data sources — fixes Swagger UI
     version dropdown for Minimal APIs. Separated AddMvc() and AddApiExplorer() registrations so
     the IApiVersionDescriptionProvider discovers both controller attributes and Minimal API
     version sets correctly.