From e7aaacc41077a6ff494773f01b9e065b911855e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E9=B9=8F?= <1069269649@qq.com> Date: Sun, 26 Oct 2025 15:35:38 +0800 Subject: [PATCH] =?UTF-8?q?upd:=20=E7=BD=91=E5=85=B3=E6=B7=BB=E5=8A=A0swag?= =?UTF-8?q?ger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gateways/KonSoft.InternalGateway/Program.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gateways/KonSoft.InternalGateway/Program.cs b/gateways/KonSoft.InternalGateway/Program.cs index 3701eee..b6677f5 100644 --- a/gateways/KonSoft.InternalGateway/Program.cs +++ b/gateways/KonSoft.InternalGateway/Program.cs @@ -2,6 +2,7 @@ using KonSoft.InternalGateway; using KonSoft.InternalGateway.Extensions; using KonSoft.Shared.Hosting.AspNetCore; using Microsoft.AspNetCore.Rewrite; +using Microsoft.OpenApi.Models; using Serilog; var assemblyName = typeof(Program).Assembly.GetName().Name!; @@ -19,16 +20,28 @@ try .AddAppSettingsSecretsJson() .UseAutofac() .UseSerilog(); + + builder.Services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new OpenApiInfo + { + Title = "Gateway", + Version = "v1" + }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + }); + + builder.Services.AddReverseProxy() .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); builder.Services.AddControllers(); await builder.AddApplicationAsync(); var app = builder.Build(); await app.InitializeApplicationAsync(); + app.UseSwaggerUIWithYarp(); app.MapReverseProxy(); app.MapGet("/heath", () => "Online"); - app.UseSwaggerUIWithYarp(); - app.UseRewriter(new RewriteOptions().AddRedirect("^(|\\|\\s+)$", "/swagger")); await app.RunAsync(); return 0;