'SwaggerUI base path IIS
I have swagger UI defined as follows in my netcore 6 app
app.UseSwaggerUI(x =>
{
var descriptions = apiVersionDescriptionProvider.ApiVersionDescriptions.OrderByDescending(x => x.ApiVersion.MajorVersion).ThenByDescending(x => x.ApiVersion.MinorVersion).ToList();
var defaultDescription = descriptions.Where(x => x.ApiVersion == defaultApiVersion).SingleOrDefault();
descriptions.Remove(defaultDescription);
descriptions.Insert(0, defaultDescription);
foreach (var description in descriptions)
x.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant() + (description.ApiVersion == defaultApiVersion ? " (current)" : ""));
x.DefaultModelsExpandDepth(-1);
x.InjectStylesheet("/swagger-ui/custom.min.css");
x.InjectJavascript("/swagger-ui/custom.js");
});
This works fine and peachy on dev machine. On the server, I have to put my app in {iisroot}/eea/corat folder. All the swagger URLs are broken as they reference straight from {issroot}
So I tried adding
x.RoutePrefix = "eea/corat/"; right above var descriptions =
This however makes my application not even run in dev. The application opens to a white screen and crashes in a few seconds.
How do I tell swagger UI about my prefix correctly?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
