Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Support multi-tenant use case for SwaggerGenOptions
Currently, a ISwaggerProvider
instance is created using an internal method on the SwaggerGenOptions
class, and an instance of this class is supplied from the DI container using IOptions<SwaggerGenOptions>
. See the code here.
I have a multi-tenant API that makes use of a multi-tenant openid authority for authentication of the swagger client, so I need to provide different options per tenant URL path. I typically do this by using IOptionsMonitor<TOptions>
rather than IOptions<TOptions>
, and then I implement the monitor class to supply the dynamic, per-tenant data.
My problem here though is that I cannot simply write the following as the CreateSwaggerProvider
method is internal to the SwaggerGen project.
private static ISwaggerProvider CreateSwaggerProvider(IServiceProvider serviceProvider)
{
var swaggerGenOptions = serviceProvider.GetRequiredService<IOptionsMonitor<SwaggerGenOptions>>().Value;
return swaggerGenOptions.CreateSwaggerProvider(serviceProvider);
}
So, can I request a change please. Either use IOptionsMonitor rather than IOptions, or make the CreateSwaggerProvider method public or protected.