I have a C# WebForms application where I'm using swagger initialized in my Global.asax in the following way:
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapOwinPath("swagger", app =>
{
app.UseSwaggerUi3(typeof(Global).Assembly, settings =>
{
settings.MiddlewareBasePath = "/swagger";
settings.DocumentTitle = "API";
settings.GeneratorSettings.DefaultUrlTemplate = "api/{controller}/{action}/{id}";
settings.GeneratorSettings.Title = "API";
settings.GeneratorSettings.Description = "REST interface for API";
settings.GeneratorSettings.UseControllerSummaryAsTagDescription = true;
});
});
}
I often deploy to a app pool and website that supports may different URL's for the various instances I'll have:
etc..
I've noticed that when I navigate to the swagger URL on one of my websites that often times the URL it wrong, for instance, when I navigate to "https://testci2.ABC.com/swagger" I see a "BaseURL" of:
[ Base URL: testci1.ABC.com ]
Which is wrong, and causes all my swagger services call to fail due to IIS security around cross URL requests.
There is a great deal of discussion on this topic, but very little specific to C#. How to I get NSwag to generate a base URL("host" technically) from I've navigated to, it seems to be caching and/or incorrectly generating and storing the wrong baseURL?