We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swashbuckle 4 uses IOptions pattern, so creating temporary container is not required anymore.
IOptions
This can be done using IConfigureOptions
IConfigureOptions
public interface ISwaggerVersionInfoProvider { Info GetVersionInfo(ApiVersionDescription apiDescription); } public class SwaggerVersionAutoDiscovery : IConfigureOptions<SwaggerGenOptions> { private readonly IApiVersionDescriptionProvider _versionDescriptionProvider; private readonly ISwaggerVersionInfoProvider _swaggerVersionInfoProvider; public SwaggerVersionAutoDiscovery(IApiVersionDescriptionProvider versionDescriptionProvider, ISwaggerVersionInfoProvider swaggerVersionInfoProvider) { _versionDescriptionProvider = versionDescriptionProvider ?? throw new ArgumentNullException(nameof(versionDescriptionProvider)); _swaggerVersionInfoProvider = swaggerVersionInfoProvider ?? throw new ArgumentNullException(nameof(swaggerVersionInfoProvider)); } public void Configure(SwaggerGenOptions options) { foreach (var description in _versionDescriptionProvider.ApiVersionDescriptions) { options.SwaggerDoc(description.GroupName, _swaggerVersionInfoProvider.GetVersionInfo(description)); } } }
Startup.cs code
// todo: register your ISwaggerVersionInfoProvider implementation // services.Add(...); // Add SwaggerGenOptions configurator services.AddTransient<IConfigureOptions<SwaggerGenOptions>, SwaggerVersionAutoDiscovery>();
The text was updated successfully, but these errors were encountered:
78ff16a
Ah … thanks for the tip. I've updated the examples. ;)
Sorry, something went wrong.
commonsensesoftware
No branches or pull requests
Swashbuckle 4 uses
IOptions
pattern, so creating temporary containeris not required anymore.
This can be done using
IConfigureOptions
Startup.cs code
The text was updated successfully, but these errors were encountered: