From f060641e971dc61461795b44552aaf7fb10e9fcb 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 16:03:23 +0800 Subject: [PATCH] upd: UseSwaggerUIWithYarp --- .../Extensions/YarpSwaggerUIBuilderExtensions.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gateways/KonSoft.InternalGateway/Extensions/YarpSwaggerUIBuilderExtensions.cs b/gateways/KonSoft.InternalGateway/Extensions/YarpSwaggerUIBuilderExtensions.cs index 1fd28ff..425bba7 100644 --- a/gateways/KonSoft.InternalGateway/Extensions/YarpSwaggerUIBuilderExtensions.cs +++ b/gateways/KonSoft.InternalGateway/Extensions/YarpSwaggerUIBuilderExtensions.cs @@ -1,4 +1,5 @@ -using Yarp.ReverseProxy.Configuration; +using Microsoft.AspNetCore.Builder; +using Yarp.ReverseProxy.Configuration; namespace KonSoft.InternalGateway.Extensions { public static class YarpSwaggerUIBuilderExtensions @@ -24,7 +25,6 @@ namespace KonSoft.InternalGateway.Extensions .Select(t => t.First()) .Distinct() .ToList(); - foreach (var clusterGroup in groupedClusters) { var routeConfig = yarpConfig.Routes.FirstOrDefault(q => @@ -34,8 +34,9 @@ namespace KonSoft.InternalGateway.Extensions logger.LogWarning($"Swagger UI: Couldn't find route configuration for {clusterGroup.ClusterId}..."); continue; } - - options.SwaggerEndpoint($"{clusterGroup.Value.Address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API"); + + // options.SwaggerEndpoint($"{clusterGroup.Value.Address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API"); + options.SwaggerEndpoint(new Uri(new Uri(clusterGroup.Value.Address), "/swagger/v1/swagger.json").AbsoluteUri, $"{routeConfig.RouteId} API"); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }