IIS site within virtual directory Swagger UI end point
Unfortunately, None of them works for me.
I have tried all of them.
Working solution:
app.UseSwagger(c => {
c.RouteTemplate = "swagger/{documentName}/swagger.json";
});
app.UseSwaggerUI(c => {
c.SwaggerEndpoint("v1/swagger.json", "My API V1");
});
I changed this line in Swagger UI configure (Startup.cs):
c.SwaggerEndpoint("/prueba/swagger/v1/swagger.json", "Swagger (....)");
The problem is more relevant to swagger than Environment variable. Swagger does support the virtual directory which then the configuration should look like below. Note that virtual directory doesn't affect the UI End point.
app.UseSwagger(c =>
{
//Change the path of the end point , should also update UI middle ware for this change
c.RouteTemplate = "api-docs/{documentName}/swagger.json";
});
app.UseSwaggerUI(c =>
{
//Include virtual directory if site is configured so
c.RoutePrefix = "api-docs";
c.SwaggerEndpoint("v1/swagger.json", "Api v1");
});
Adding "../" works for websites hosted under virtual directory and without virtual directory
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("../swagger/v1/swagger.json", "TestService");
});