Aicrosoft.Extensions.Swagger
8.0.0-beta.260127.1
This is a prerelease version of Aicrosoft.Extensions.Swagger.
dotnet add package Aicrosoft.Extensions.Swagger --version 8.0.0-beta.260127.1
NuGet\Install-Package Aicrosoft.Extensions.Swagger -Version 8.0.0-beta.260127.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="Aicrosoft.Extensions.Swagger" Version="8.0.0-beta.260127.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aicrosoft.Extensions.Swagger" Version="8.0.0-beta.260127.1" />
<PackageReference Include="Aicrosoft.Extensions.Swagger" />
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 Aicrosoft.Extensions.Swagger --version 8.0.0-beta.260127.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Aicrosoft.Extensions.Swagger, 8.0.0-beta.260127.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 Aicrosoft.Extensions.Swagger@8.0.0-beta.260127.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=Aicrosoft.Extensions.Swagger&version=8.0.0-beta.260127.1&prerelease
#tool nuget:?package=Aicrosoft.Extensions.Swagger&version=8.0.0-beta.260127.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Aicrosoft.Extensions.Swagger
Aicrosoft.Extensions.Swagger is a high-level wrapper and extension for Swashbuckle.AspNetCore, designed to provide consistent, powerful, and easy-to-configure API documentation support for microservices or modular web applications under the Aicrosoft framework.
Design Goals
- Automated Modular Grouping: Implements automatic grouping based on the assembly (module) where controllers reside using
IApiDescriptionGroupCollectionProvider, solving the issue of API clutter in large projects. - Unified Security & Authorization: Built-in support for JWT (Bearer) and OAuth2, providing
AuthorizeCheckOperationFilterto automatically show or hide lock icons on the UI based on code attributes ([Authorize]/[AllowAnonymous]). - Multi-version Compatibility: Seamlessly integrates with
Asp.Versioning, supporting the generation of different document definitions based on version numbers. - Standardized Output: Provides out-of-the-box features like URL lowercasing, obsolete interface tagging, and automatic merging of XML comments from multiple projects.
- Configuration-Driven: Deeply integrated with
AppSettings, allowing dynamic enabling/disabling of Swagger and detailed authorization configuration via configuration files.
Key Features
- Module Grouping: Automatically identifies
GroupNameand maps it to a Swagger Endpoint. - JWT Lock Icons: Automatically recognizes authentication attributes, eliminating the need for complex manual
OpenApiSecurityRequirementconfiguration. - Path Transformation:
PathLowercaseDocumentFilterensures RESTful paths comply with lowercase conventions. - Cross-module XML Comments: Automatically loads XML comment files related to plugin assemblies.
- Anonymous Access Protection: Automatically configures middleware to allow access to
/swaggereven when global authentication is enabled.
Usage
1. Installation
Reference the following package in your web project (typically the Host or Api project):
Aicrosoft.Extensions.Swagger
2. Define Swagger Configuration Class
Inherit from SwaggerGroupConfigureOptions to define your API description mapping logic:
public class MySwaggerOptions(IServiceProvider provider) : SwaggerGroupConfigureOptions(provider)
{
protected override OpenApiInfo CreateModuleOpenApiInfo(Assembly moduleAssembly, IEnumerable<ApiVersion>? apiVersions = null)
{
return new OpenApiInfo
{
Title = $"My API - {moduleAssembly.GetName().Name}",
Version = apiVersions?.FirstOrDefault()?.ToString() ?? "v1",
Description = "API documentation for my service modules."
};
}
}
3. Register Services in WebApplicationBuilder
var builder = WebApplication.CreateBuilder(args);
// Register Swagger service and bind the configuration class
builder.AddSwaggerService<MySwaggerOptions>();
var app = builder.Build();
// Enable Swagger middleware
app.UseSwaggerService();
app.Run();
4. Configuration (appsettings.json)
{
"SwaggerUI": {
"Enable": true,
"ClientId": "your-client-id",
"Scopes": {
"api.read": "Read access to the API",
"api.write": "Write access to the API"
}
},
"Auth": {
"Enable": true
}
}
Notes
- XML Comments: To see method comments on the UI, ensure
<GenerateDocumentationFile>true</GenerateDocumentationFile>is enabled in your WebAPI projects'.csprojfiles. - Path Conflicts:
PathLowercaseDocumentFilteris enabled by default. If your code has explicit case dependencies in paths, please adjust accordingly. - Grouping Rules: Grouping is based on
ApiExplorerSettings(GroupName = "...")by default. IfGroupNameis not specified, it may not be correctly mounted to an endpoint.
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Aicrosoft.Extensions.Hosting (>= 8.0.0-beta.260127.1)
- Aicrosoft.Extensions.Mvc (>= 8.0.0-beta.260127.1)
- Asp.Versioning.Mvc (>= 8.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- Swashbuckle.AspNetCore (>= 7.3.1)
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.0.0-beta.260127.1 | 30 | 1/27/2026 |
| 8.0.0-beta.251110.1 | 186 | 11/10/2025 |