upd: 网关swagger

This commit is contained in:
于鹏
2025-10-26 22:13:17 +08:00
parent b2bccc34f5
commit 802624e7ea
3 changed files with 14 additions and 2 deletions

View File

@ -25,6 +25,8 @@ namespace KonSoft.InternalGateway.Extensions
.Select(t => t.First())
.Distinct()
.ToList();
var gatewayUrl = configuration["GatewayUrl"];
foreach (var clusterGroup in groupedClusters)
{
var routeConfig = yarpConfig.Routes.FirstOrDefault(q =>
@ -36,7 +38,7 @@ namespace KonSoft.InternalGateway.Extensions
}
// 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.SwaggerEndpoint(new Uri(new Uri(!string.IsNullOrWhiteSpace(gatewayUrl)? gatewayUrl: clusterGroup.Value.Address), "/swagger/v1/swagger.json").AbsoluteUri, $"{routeConfig.RouteId} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}