diff --git a/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerService.cs b/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerService.cs
index 7120519..5487e3b 100644
--- a/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerService.cs
+++ b/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerService.cs
@@ -13,6 +13,6 @@ public class SwaggerService
///
/// Gets or sets the path.
///
- public string Path { get; set; } = "/swagger/v1/swagger.json";
+ public string Path { get; set; }
}
}
diff --git a/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerServiceDiscoveryProvider.cs b/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerServiceDiscoveryProvider.cs
index bd5b7a3..3029bfd 100644
--- a/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerServiceDiscoveryProvider.cs
+++ b/src/MMLib.SwaggerForOcelot/ServiceDiscovery/SwaggerServiceDiscoveryProvider.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using Kros.Extensions;
+using Kros.Extensions;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using MMLib.SwaggerForOcelot.Configuration;
@@ -13,6 +10,9 @@
using Ocelot.ServiceDiscovery.Providers;
using Ocelot.Values;
using Swashbuckle.AspNetCore.Swagger;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
namespace MMLib.SwaggerForOcelot.ServiceDiscovery
{
@@ -110,6 +110,11 @@ private async Task GetSwaggerUri(SwaggerEndPointConfig endPoint, RouteOptio
{
Path = endPoint.Service.Path
};
+ if (builder.Path.IsNullOrEmpty())
+ {
+ string version = endPoint.Version.IsNullOrEmpty() ? "v1" : endPoint.Version;
+ builder.Path = $"/swagger/{version}/swagger.json";
+ };
return builder.Uri;
}