VOOZH about

URL: https://www.nuget.org/packages/Galosys.Foundation.Swashbuckle/

⇱ NuGet Gallery | Galosys.Foundation.Swashbuckle 26.5.20.1




Galosys.Foundation.Swashbuckle 26.5.20.1

dotnet add package Galosys.Foundation.Swashbuckle --version 26.5.20.1
 
 
NuGet\Install-Package Galosys.Foundation.Swashbuckle -Version 26.5.20.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="Galosys.Foundation.Swashbuckle" Version="26.5.20.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Galosys.Foundation.Swashbuckle" Version="26.5.20.1" />
 
Directory.Packages.props
<PackageReference Include="Galosys.Foundation.Swashbuckle" />
 
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 Galosys.Foundation.Swashbuckle --version 26.5.20.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Galosys.Foundation.Swashbuckle, 26.5.20.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 Galosys.Foundation.Swashbuckle@26.5.20.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=Galosys.Foundation.Swashbuckle&version=26.5.20.1
 
Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.Swashbuckle&version=26.5.20.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Galosys.Foundation.Swashbuckle

成熟度: 🟢 稳定 — 生产可用,测试充分,活跃维护

简介

基于 Swashbuckle 的 Swagger/OpenAPI 集成模块,为 ASP.NET Core API 提供自动化的在线文档生成、认证支持和自定义头部扩展。

特性

  • 自动生成 RESTful API 和 gRPC 在线文档
  • 支持 JWT/Bearer、Basic、ApiKey 三种认证方式
  • 自动注入业务头部(租户ID、应用ID、语言、客户端类型)
  • 支持请求签名验证(防篡改、防重放)
  • 枚举自动显示 DescriptionAttribute 注释
  • 支持 Basic 认证保护 Swagger UI
  • 自动发现 XML 文档注释
  • 支持 [NonSwaggerGen] 特性隐藏指定接口

安装

dotnet add package Galosys.Foundation.Swashbuckle

使用

基础配置

appsettings.json 中添加配置:

{
 "Application": {
 "Name": "MyAPI"
 },
 "Swagger": {
 "DisplaySchema": false,
 "AuthEnabled": true,
 "Users": {
 "admin": "admin123"
 }
 }
}

注册服务

// Program.cs
builder.Services.AddSwaggerGen(builder.Configuration);

// 或手动指定名称
builder.Services.AddSwaggerGen("MyAPI");

启用中间件

app.UseSwaggerGen();

// 自定义 UI 配置
app.UseSwaggerGen(opt =>
{
 opt.DefaultModelsExpandDepth(-1);
});

隐藏接口

[NonSwaggerGen]
[ApiController]
public class InternalController : ControllerBase
{
 // 此控制器将不出现在文档中
}

gRPC 文档

自动集成 gRPC Swagger,无需额外配置。

核心类

类/扩展方法 说明
AddSwaggerGen() 注册 Swagger 服务
UseSwaggerGen() 启用 Swagger 中间件
SwaggerOptions 配置选项(鉴权、Schema显示)
NonSwaggerGenAttribute 标记隐藏的控制器/方法
SwaggerAuthMiddleware Basic 认证中间件
AuthOperationFilter 自动添加认证安全要求
TenantIdHeaderOperationFilter 注入 x-tenant-id 头部
AppIdHeaderOperationFilter 注入 x-app-id 头部
LocalizationHeaderOperationFilter 注入 Accept-Language 头部
ClientTypeHeaderOperationFilter 注入 x-client-type 头部
SignatureHeaderOperationFilter 注入签名验证头部
EnumSchemaFilter 枚举显示 Description 注释

依赖

  • Swashbuckle.AspNetCore.Swagger
  • Swashbuckle.AspNetCore.SwaggerGen
  • Swashbuckle.AspNetCore.SwaggerUI
  • Microsoft.AspNetCore.Grpc.Swagger
  • Galosys.Foundation.Core
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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 (2)

Showing the top 2 NuGet packages that depend on Galosys.Foundation.Swashbuckle:

Package Downloads
Galosys.Foundation.AspNetCore.MultiTenancy

Galosys.Foundation快速开发库

Galosys.AspNetCore.App

Galosys.Foundation快速开发库

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.5.20.1 120 5/20/2026
26.5.19.1 111 5/19/2026
26.5.18.1 117 5/18/2026
26.5.15.1 111 5/15/2026
26.5.12.3 115 5/12/2026
26.5.12.2 108 5/12/2026
26.4.27.1-rc1 114 4/26/2026
26.4.25.1-rc1 120 4/25/2026
26.4.22.2-rc7 111 4/22/2026
26.4.22.2-rc6 113 4/22/2026
26.4.22.2-rc4 109 4/22/2026
26.4.22.2-rc3 109 4/22/2026
26.4.12.8-rc1 115 4/12/2026
26.4.12.7-rc1 112 4/12/2026
26.1.30.1-rc1 162 1/30/2026
26.1.29.1 178 1/29/2026
26.1.28.5 172 1/28/2026
26.1.28.4 164 1/28/2026
26.1.28.2 173 1/28/2026
26.1.23.6 166 1/23/2026
Loading failed