I have two kubernetes services deployed on a AKS, they receive traffic from a Nginx Ingress Controller. The endpoints for these two services are https:<dns>/service1
and https:<dns>/service2
. Now I want to set up Swagger for each services. Below is how I set up Swagger UI for one of the services.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/service1/swagger/v1/swagger.json", "API V1");
});
With this configuration, I can get access to swagger by https:<dns>/service1/swagger
.
Now the problem is, in Swagger UI, when I want to test the api by clicking the "Try it out" button then Excute button, the url that Swagger UI access is https:<dns>/api/v1/contoller
instead of https:<dns>/service1/api/v1/contoller
. Which means that Swagger UI is not aware of the existance of path /service1/
. I found several related questions like this one How to change base url of Swagger in ASP.NET core
. But they are not the solution for my problem. My guess is I need to set a base path for Swagger. If anyone could tell me how to configure base path for Swagger in ASP.NET core 2.0, it would be much appreciated.