I have followed the top article : .Net Core 3.1 Remove Schema on Swagger UI
I applied this filter:
public class RemoveSchemasFilter : IDocumentFilter
{
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
IDictionary<string, OpenApiSchema> _remove = swaggerDoc.Components.Schemas;
foreach (KeyValuePair<string, OpenApiSchema> _item in _remove)
{
swaggerDoc.Components.Schemas.Remove(_item.Key);
}
}
}
I have added it here:
services.AddSwaggerGen(options =>
{
options.OperationFilter<AddRequiredHeaderParameter>(Configuration.GetSection("DefaultConfig")["TenantId"]);
options.DocumentFilter<RemoveSchemasFilter>();
}
All good Schema is removed from the bottom of Swagger UI. However, when I click on a method it brings a dialogue of errors. It works but this windows stays on top and it is very annoying.
Let's solve this problem together as it was unsolved previously!
