upd: UseSwaggerUIWithYarp

This commit is contained in:
于鹏
2025-10-26 16:03:23 +08:00
parent e7aaacc410
commit f060641e97

View File

@ -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"]);
}