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"/>
<!-- Swagger-->
<PackageReference Update="Swashbuckle.AspNetCore.SwaggerUI" Version="10.0.1"/>
<PackageReference Update="Swashbuckle.AspNetCore" Version="10.0.1"/>
<PackageReference Update="Swashbuckle.AspNetCore.Annotations" Version="10.0.1"/>
<PackageReference Update="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.4"/>
<PackageReference Update="Swashbuckle.AspNetCore" Version="9.0.4"/>
<PackageReference Update="Swashbuckle.AspNetCore.Annotations" Version="9.0.4"/>
<!-- Serilog 日志-->
<PackageReference Update="Serilog" Version="4.3.0"/>

View File

@ -2,7 +2,7 @@
<configuration>
<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" />
</packageSources>
</configuration>

View File

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

View File

@ -148,16 +148,13 @@ public partial class IoTHttpApiHostModule
context.Services.AddSwaggerGen(
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" });
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>();
groupNames.ForEach(group =>
@ -210,12 +207,18 @@ public partial class IoTHttpApiHostModule
Scheme = JwtBearerDefaults.AuthenticationScheme,
BearerFormat = "JWT"
});
options.AddSecurityRequirement(document => new OpenApiSecurityRequirement
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecuritySchemeReference(JwtBearerDefaults.AuthenticationScheme, document),
new List<string>()
}
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme, Id = "Bearer"
}
},
new List<string>()
}
});
options.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme()
@ -226,11 +229,15 @@ public partial class IoTHttpApiHostModule
Description = "多语言设置系统预设语言有zh-Hans、en默认为zh-Hans",
});
options.AddSecurityRequirement(document => new OpenApiSecurityRequirement
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecuritySchemeReference("ApiKey", document),
new List<string>()
new OpenApiSecurityScheme
{
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.Serialization;
using System.Text.Unicode;
using Volo.Abp.Autofac;
using Volo.Abp.BlobStoring.FileSystem;
using Volo.Abp.EntityFrameworkCore.PostgreSql;
using Volo.Abp.Swashbuckle;
namespace JiShe.IoT
@ -25,7 +27,7 @@ namespace JiShe.IoT
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpBlobStoringFileSystemModule),
typeof(AbpDistributedLockingModule),
typeof(AbpSwashbuckleModule)
typeof(AbpEntityFrameworkCorePostgreSqlModule)
//typeof(AbpBackgroundJobsHangfireModule)
)]
public partial class IoTHttpApiHostModule : AbpModule

View File

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