Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
351 stars 93 forks source link

Error with gateway hosted under https://example.com/internal-gateway instead of https://example.com #292

Open jducobu opened 5 months ago

jducobu commented 5 months ago

I use dotnet 8 and the nuget package 8.2.0 without updating the ocelot package (a new version 23.2.0 was released). The ocelot gatewat is accessible from the url https://example.com/internal-gateway/... I use this code to configure the SwaggerForOcelot (simimlar from the demos found on this repos)

string prefix = "/internal-gateway";

app.UsePathBase(prefix);
app.UseSwaggerForOcelotUI(opt =>
{
    opt.DownstreamSwaggerEndPointBasePath = $"{prefix}/swagger/docs";
    opt.PathToSwaggerGenerator = "/swagger/docs";
}).UseOcelot().GetAwaiter().GetResult();

image

Expected behavior The swagger ui has to load the swagger configuration from https://example.com/internal-gateway/swagger/docs/v1/forms-api as expected (see the printscreen below) and not https://example.com//swagger/docs/v1/forms-api

image

To Reproduce The Ocelot route configuration:

"GlobalConfiguration": {
  "BaseUrl": "https://example.com/internal-gateway"
},
"Routes": [
  {
    "DownstreamPathTemplate": "/forms/{everything}",
    "DownstreamScheme": "https",
    "DownstreamHostAndPorts": [
      {
        "Host": "localhost",
        "Port": 33031
      }
    ],
    "UpstreamPathTemplate": "/forms-api/{everything}",
    "UpstreamHttpMethod": [ "Get", "Post" ],
    "SwaggerKey": "forms-api"
  }
],
"SwaggerEndPoints": [
  {
    "Key": "forms-api",
    "Config": [
      {
        "Name": "Forms Api",
        "Version": "v1",
        "Url": "https://localhost:33031/swagger/v1/swagger.json"
      }
    ]
  }