SwaggerGenOptionsExtensions Class
HAKOM.Documentation.Http.Net.Api.Extensions
Section titled “HAKOM.Documentation.Http.Net.Api.Extensions”Provides extension methods on Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions for non-trivial modification of generated OpenAPI documents.
public static class SwaggerGenOptionsExtensionsInheritance System.Object 🡒 SwaggerGenOptionsExtensions
Methods
Section titled “Methods”SwaggerGenOptionsExtensions.AddCustomModelBinderFilters<TModel>(this SwaggerGenOptions) Method
Section titled “SwaggerGenOptionsExtensions.AddCustomModelBinderFilters<TModel>(this SwaggerGenOptions) Method”Registers Swashbuckle.AspNetCore.SwaggerGen.IOperationFilter instances that cause proper documentation of parameters bound by ICustomModelBinder implementations.
public static Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions AddCustomModelBinderFilters<TModel>(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions);Type parameters
Section titled “Type parameters”TModel
The model for which a custom model binder is being used.
Parameters
Section titled “Parameters”swaggerGenOptions Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions
The Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions used to configure the creation of the OpenAPI document.
Returns
Section titled “Returns”Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions
The swaggerGenOptions for chaining of additional configuration method calls.
Remarks
Section titled “Remarks”Whenever an implementation of ICustomModelBinder is used to bind parameters from the route or query to a complex object, the automatically generated OpenAPI specification of these parameters is likely to be wrong.
Therefore, in addition to registering the custom model binder, one should also call this method with the TModel supported by the binder. This cause operation filters to be registered that will - to the best of their ability - extract information about the models underlying paramters from the binder and document them accordingly.