Skip to content

Commit

Permalink
Respect configured API version in downstream path
Browse files Browse the repository at this point in the history
  • Loading branch information
satano committed Jul 9, 2024
1 parent ecc9644 commit 309dec2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class SwaggerService
/// <summary>
/// Gets or sets the path.
/// </summary>
public string Path { get; set; } = "/swagger/v1/swagger.json";
public string Path { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -110,6 +110,11 @@ private async Task<Uri> 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;
}
Expand Down

0 comments on commit 309dec2

Please sign in to comment.