diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj
index 6cca04a3..003a4704 100644
--- a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj
+++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/SwaggerConfigurationHelper.cs b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/SwaggerConfigurationHelper.cs
index 6e79b550..346fae75 100644
--- a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/SwaggerConfigurationHelper.cs
+++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/SwaggerConfigurationHelper.cs
@@ -38,4 +38,28 @@ public static class SwaggerConfigurationHelper
options.CustomSchemaIds(type => type.FullName);
});
}
+
+ public static void ConfigureWithOidc(
+ ServiceConfigurationContext context,
+ string authority,
+ string[] scopes,
+ string apiTitle,
+ string apiVersion = "v1",
+ string apiName = "v1",
+ string[]? flows = null,
+ string? discoveryEndpoint = null
+ )
+ {
+ context.Services.AddAbpSwaggerGenWithOidc(
+ authority: authority,
+ scopes: scopes,
+ flows: flows,
+ discoveryEndpoint: discoveryEndpoint,
+ options =>
+ {
+ options.SwaggerDoc(apiName, new OpenApiInfo { Title = apiTitle, Version = apiVersion });
+ options.DocInclusionPredicate((docName, description) => true);
+ options.CustomSchemaIds(type => type.FullName);
+ });
+ }
}
\ No newline at end of file
diff --git a/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj b/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj
index 84d1a5d6..4f2af131 100644
--- a/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj
+++ b/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs b/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs
index 508884a6..46fb6048 100644
--- a/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs
+++ b/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs
@@ -1,5 +1,4 @@
-using System.Linq;
-using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -18,32 +17,12 @@ public static class YarpSwaggerUIBuilderExtensions
{
var configuration = context.ServiceProvider.GetRequiredService();
var logger = context.ServiceProvider.GetRequiredService>();
- var proxyConfigProvider = context.ServiceProvider.GetRequiredService();
- var yarpConfig = proxyConfigProvider.GetConfig();
+ var proxyConfig = context.ServiceProvider.GetRequiredService().GetConfig();
- var routedClusters = yarpConfig.Clusters
- .SelectMany(t => t.Destinations,
- (clusterId, destination) => new {clusterId.ClusterId, destination.Value});
-
- var groupedClusters = routedClusters
- .GroupBy(q => q.Value.Address)
- .Select(t => t.First())
- .Distinct()
- .ToList();
-
- foreach (var clusterGroup in groupedClusters)
+ foreach (var cluster in proxyConfig.Clusters)
{
- var routeConfig = yarpConfig.Routes.FirstOrDefault(q =>
- q.ClusterId == clusterGroup.ClusterId);
- if (routeConfig == null)
- {
- 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.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
- options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
+ options.SwaggerEndpoint($"/swagger-json/{cluster.ClusterId}/swagger/v1/swagger.json",
+ $"{cluster.ClusterId} API");
}
});