Open prabuw opened 5 years ago
@prabuw
Thank you for the report.
I add an extension method to IFunctionsHostBuilder
.
Hi @prabuw . Thank you issue.
IFunctionHostBuilder is Azure Functions DI point. But it is not support AddExtension extension method. https://github.com/yuka1984/azure-functions-extensions-swashbuckle/blob/master/src/AzureFunctions.Extensions.Swashbuckle/AzureFunctions.Extensions.Swashbuckle/SwashBuckleStartupExtension.cs#L19
if IFunctionsHostBulder
support AddExtension method, I can support it.
My workaround for this is as follows (v1.4.4):
public class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
builder.AddSwashBuckle(Assembly.GetExecutingAssembly());
Configure(new FunctionsHostBuilder(builder.Services));
}
private static void Configure(IFunctionsHostBuilder builder)
{
// register other services here
}
}
internal class FunctionsHostBuilder : IFunctionsHostBuilder
{
public FunctionsHostBuilder(IServiceCollection services)
{
var serviceCollection = services;
Services = serviceCollection ?? throw new ArgumentNullException(nameof (services));
}
public IServiceCollection Services { get; }
}
nice workaround, it might be better to go the other way since IFunctionsHostBuilder is the new hotness, fake up an IWebJobsStartup by passing in services and calling the existing extension on it
The
AddSwashbuckle
extension method to be used on start up depends on working withIWebJobsBuilder
. However, this doesn't work with the new dependency injection extension released from Microsoft. It comes withIFunctionsHostBuilder
.Can we add another extension to allow it to work with the
IFunctionsHostBuilder
? I'm happy to discuss the approach and raise a PR if you are open to a contribution.