Microsoft OpenApi 还原

This commit is contained in:
陈益 2026-01-15 22:09:14 +08:00
parent 8da8fb14ca
commit 17e8fc52ad
6 changed files with 31 additions and 20 deletions

View File

@ -63,9 +63,9 @@
<PackageReference Update="Savorboard.CAP.InMemoryMessageQueue" Version="8.2.1"/> <PackageReference Update="Savorboard.CAP.InMemoryMessageQueue" Version="8.2.1"/>
<!-- Swagger--> <!-- Swagger-->
<PackageReference Update="Swashbuckle.AspNetCore.SwaggerUI" Version="10.0.1"/> <PackageReference Update="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.4"/>
<PackageReference Update="Swashbuckle.AspNetCore" Version="10.0.1"/> <PackageReference Update="Swashbuckle.AspNetCore" Version="9.0.4"/>
<PackageReference Update="Swashbuckle.AspNetCore.Annotations" Version="10.0.1"/> <PackageReference Update="Swashbuckle.AspNetCore.Annotations" Version="9.0.4"/>
<!-- Serilog 日志--> <!-- Serilog 日志-->
<PackageReference Update="Serilog" Version="4.3.0"/> <PackageReference Update="Serilog" Version="4.3.0"/>

View File

@ -2,7 +2,7 @@
<configuration> <configuration>
<packageSources> <packageSources>
<add key="JiSheTeam" value="http://192.168.111.248:9511/nuget/JiSheTeam/v3/index.json" protocolVersion="3" allowInsecureConnections="true" /> <add key="JiSheTeam" value="http://localhost:5020/v3/index.json" protocolVersion="3" allowInsecureConnections="true" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> <add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources> </packageSources>
</configuration> </configuration>

View File

@ -36,7 +36,7 @@ global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Logging.Abstractions; global using Microsoft.Extensions.Logging.Abstractions;
global using Microsoft.Extensions.Options; global using Microsoft.Extensions.Options;
global using Microsoft.IdentityModel.Tokens; global using Microsoft.IdentityModel.Tokens;
global using Microsoft.OpenApi; global using Microsoft.OpenApi.Models;
global using JiShe.IoT; global using JiShe.IoT;
global using Serilog; global using Serilog;
global using StackExchange.Redis; global using StackExchange.Redis;

View File

@ -148,16 +148,13 @@ public partial class IoTHttpApiHostModule
context.Services.AddSwaggerGen( context.Services.AddSwaggerGen(
options => options =>
{ {
// 隐藏ABP默认的端点
options.HideAbpEndpoints();
// 文件下载类型 // 文件下载类型
options.MapType<FileContentResult>(() => new OpenApiSchema() { Type = JsonSchemaType.String, Format = "binary" }); options.MapType<FileContentResult>(() => new OpenApiSchema() { Type = "file" });
options.SwaggerDoc("AbpPro", new OpenApiInfo { Title = "AbpPro API", Version = "v1" }); options.SwaggerDoc("AbpPro", new OpenApiInfo { Title = "AbpPro API", Version = "v1" });
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
var groupNames = System.EnumExtensions.GetEnumTypeValueNameList<SwaggerGroupEnum>(); var groupNames = EnumExtensions.GetEnumTypeValueNameList<SwaggerGroupEnum>();
var excludeSwaggerGroups = configuration.GetSection("ExcludeSwaggerGroup").Get<List<string>>() ?? new List<string>(); var excludeSwaggerGroups = configuration.GetSection("ExcludeSwaggerGroup").Get<List<string>>() ?? new List<string>();
groupNames.ForEach(group => groupNames.ForEach(group =>
@ -210,12 +207,18 @@ public partial class IoTHttpApiHostModule
Scheme = JwtBearerDefaults.AuthenticationScheme, Scheme = JwtBearerDefaults.AuthenticationScheme,
BearerFormat = "JWT" BearerFormat = "JWT"
}); });
options.AddSecurityRequirement(document => new OpenApiSecurityRequirement options.AddSecurityRequirement(new OpenApiSecurityRequirement
{ {
{ {
new OpenApiSecuritySchemeReference(JwtBearerDefaults.AuthenticationScheme, document), new OpenApiSecurityScheme
new List<string>() {
} Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme, Id = "Bearer"
}
},
new List<string>()
}
}); });
options.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme() options.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme()
@ -226,11 +229,15 @@ public partial class IoTHttpApiHostModule
Description = "多语言设置系统预设语言有zh-Hans、en默认为zh-Hans", Description = "多语言设置系统预设语言有zh-Hans、en默认为zh-Hans",
}); });
options.AddSecurityRequirement(document => new OpenApiSecurityRequirement options.AddSecurityRequirement(new OpenApiSecurityRequirement
{ {
{ {
new OpenApiSecuritySchemeReference("ApiKey", document), new OpenApiSecurityScheme
new List<string>() {
Reference = new OpenApiReference
{ Type = ReferenceType.SecurityScheme, Id = "ApiKey" }
},
Array.Empty<string>()
} }
}); });
}); });

View File

@ -6,7 +6,9 @@ using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.Unicode; using System.Text.Unicode;
using Volo.Abp.Autofac;
using Volo.Abp.BlobStoring.FileSystem; using Volo.Abp.BlobStoring.FileSystem;
using Volo.Abp.EntityFrameworkCore.PostgreSql;
using Volo.Abp.Swashbuckle; using Volo.Abp.Swashbuckle;
namespace JiShe.IoT namespace JiShe.IoT
@ -25,7 +27,7 @@ namespace JiShe.IoT
typeof(AbpCachingStackExchangeRedisModule), typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpBlobStoringFileSystemModule), typeof(AbpBlobStoringFileSystemModule),
typeof(AbpDistributedLockingModule), typeof(AbpDistributedLockingModule),
typeof(AbpSwashbuckleModule) typeof(AbpEntityFrameworkCorePostgreSqlModule)
//typeof(AbpBackgroundJobsHangfireModule) //typeof(AbpBackgroundJobsHangfireModule)
)] )]
public partial class IoTHttpApiHostModule : AbpModule public partial class IoTHttpApiHostModule : AbpModule

View File

@ -20,7 +20,6 @@
<PackageReference Include="Volo.Abp.Autofac" /> <PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" /> <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" />
<PackageReference Include="Volo.Abp.Swashbuckle" />
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" /> <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" />
<PackageReference Include="Serilog" /> <PackageReference Include="Serilog" />
@ -44,6 +43,9 @@
<PackageReference Include="Volo.Abp.DistributedLocking" /> <PackageReference Include="Volo.Abp.DistributedLocking" />
<PackageReference Include="DistributedLock.Redis" /> <PackageReference Include="DistributedLock.Redis" />
<PackageReference Include="Volo.Abp.BlobStoring.FileSystem" /> <PackageReference Include="Volo.Abp.BlobStoring.FileSystem" />
<PackageReference Include="Volo.Abp.Swashbuckle" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>