聚合 OpenApi 文档
This commit is contained in:
1 parent
6f4a338bb4
commit
f13e775ca1
9 files changed
+1873
-10
No files matched your search
@@ -4,6 +4,7 @@
|
||||
using HelloShop.ServiceDefaults.Infrastructure;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
@@ -11,6 +12,7 @@ using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -24,6 +26,12 @@ namespace HelloShop.ServiceDefaults.Extensions
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen(configureOptions);
|
||||
|
||||
services.Configure<SwaggerUIOptions>(options =>
|
||||
{
|
||||
options.DocumentTitle = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
options.InjectStylesheet("/ServiceDefaults/Resources/OpenApi/Custom.css");
|
||||
});
|
||||
|
||||
services.Configure<SwaggerGenOptions>(options =>
|
||||
{
|
||||
options.OperationFilter<AcceptLanguageHeaderOperationFilter>();
|
||||
@@ -56,6 +64,11 @@ namespace HelloShop.ServiceDefaults.Extensions
|
||||
app.UseSwagger(apiConfigureOptions);
|
||||
app.UseSwaggerUI(uiConfigureOptions);
|
||||
|
||||
app.Map("/ServiceDefaults", appBuilder => appBuilder.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = new EmbeddedFileProvider(Assembly.GetExecutingAssembly())
|
||||
}));
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,7 @@
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\OpenApi\Custom.css" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user