public void EnableSwaggerUi(string routeTemplate, Action <SwaggerUiConfig> configure = null)
{
var config = new SwaggerUiConfig(_discoveryPaths, _rootUrlResolver);
if (configure != null)
{
configure(config);
}
var apiKey = _swaggerDocsConfig.GetApiKeyDetails();
if (apiKey != null)
{
config.SetApiKeyDetails(apiKey);
}
config.SetDiscUrlsObj(_discoveryPathsObj);
_httpConfig.Routes.MapHttpRoute(
name: "swagger_ui",
routeTemplate: routeTemplate,
defaults: null,
constraints: new { assetPath = @".+" },
handler: new SwaggerUiHandler(config)
);
if (routeTemplate == DefaultRouteTemplate)
{
_httpConfig.Routes.MapHttpRoute(
name: "swagger_ui_shortcut",
routeTemplate: "swagger",
defaults: null,
constraints: null,
handler: new RedirectHandler(_rootUrlResolver, "swagger/ui/index"));
}
}