revert: 移除 swagger 功能
This commit is contained in:
parent
82cc6befaa
commit
617c72771d
|
@ -2,15 +2,12 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<IsWebProject>true</IsWebProject>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>\bin\Debug\net6.0\BootstrapAdmin.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor.Middleware" Version="1.0.0" />
|
||||
<PackageReference Include="Longbow.Logging" Version="6.0.2" />
|
||||
<PackageReference Include="Longbow.Tasks" Version="5.2.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -26,8 +26,6 @@ public static class ApplicationBuilderExtensions
|
|||
builder.UseAuthentication();
|
||||
builder.UseAuthorization();
|
||||
|
||||
builder.UseSwagger(builder.Configuration["SwaggerPathBase"].TrimEnd('/'));
|
||||
|
||||
// 激活 ICacheManager
|
||||
builder.Services.GetRequiredService<BootstrapAdmin.Caching.ICacheManager>();
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.AddLogging(logging => logging.AddFileLogger().AddCloudLogger().AddDBLogger(ExceptionsHelper.Log));
|
||||
services.AddCors();
|
||||
services.AddResponseCompression();
|
||||
services.AddControllers();
|
||||
|
||||
// 增加后台任务
|
||||
services.AddTaskServices();
|
||||
|
@ -49,8 +48,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
// 增加认证授权服务
|
||||
services.AddBootstrapAdminSecurity<AdminService>();
|
||||
|
||||
services.AddSwagger();
|
||||
|
||||
// 增加 BootstrapApp 上下文服务
|
||||
services.AddScoped<BootstrapAppContext>();
|
||||
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
|
||||
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
|
||||
// Website: https://admin.blazor.zone
|
||||
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace BootstrapAdmin.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Swagger 扩展方法
|
||||
/// </summary>
|
||||
internal static class SwaggerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Swagger 中间件
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="pathBase"></param>
|
||||
public static void UseSwagger(this IApplicationBuilder app, string pathBase)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint($"{pathBase}/swagger/v1/swagger.json", "BootstrapAdmin API V1");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注入 Swagger 服务到容器内
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public static void AddSwagger(this IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "BootstrapAdmin API"
|
||||
});
|
||||
|
||||
//Set the comments path for the swagger json and ui.
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, "BootstrapAdmin.xml");
|
||||
options.IncludeXmlComments(xmlPath);
|
||||
|
||||
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||
{
|
||||
Name = "Authorization",
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Scheme = "Bearer",
|
||||
BearerFormat = "JWT",
|
||||
In = ParameterLocation.Header,
|
||||
Description = "JWT Authorization header using the Bearer scheme."
|
||||
});
|
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
new string[]{ }
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue