I try to use Swagger with Microsoft WebAPI 2.
For the moment, I\'ve the following call in a method.
appBuilder
.ConfigureOAuth()
.UseWebApi(con
For ASP.NET Core the following pull request was created: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/486
In the meantime the following workaround can be used:
public static IApplicationBuilder UseSwaggerUI(
this IApplicationBuilder app,
Action setupAction)
{
var options = new SwaggerUIOptions();
setupAction?.Invoke(options);
// This method reads an internal property value
// http://dotnetfollower.com/wordpress/2012/12/c-how-to-set-or-get-value-of-a-private-or-internal-property-through-the-reflection/
var indexSettings = options.GetPropertyValue("IndexSettings");
// Serve swagger-ui assets with the FileServer middleware, using a custom FileProvider
// to inject parameters into "index.html"
var fileServerOptions = new FileServerOptions
{
RequestPath = string.IsNullOrWhiteSpace(options.RoutePrefix) ? string.Empty : $"/{options.RoutePrefix}",
FileProvider = new SwaggerUIFileProvider(indexSettings.ToTemplateParameters()),
EnableDefaultFiles = true,
StaticFileOptions =
{
ContentTypeProvider = new FileExtensionContentTypeProvider()
}
};
app.UseFileServer(fileServerOptions);
return app;
}
Cheers