Добавление c.DocumentFilter<XmlCommentsDocumentFilter>();
разрывает службу API с этой ошибкой
System.ObjectDisposedException: Cannot write to the response body, the
response has completed.
Object name: 'HttpResponseStream'.
Я использую https://github.com/Microsoft/aspnet-api-versioning
services.AddSwaggerGen(c =>
{
var provider = services.BuildServiceProvider().GetRequiredService<IApiVersionDescriptionProvider>();
// This is the offending line of code
c.DocumentFilter<XmlCommentsDocumentFilter>();
foreach (var description in provider.ApiVersionDescriptions)
{
c.SwaggerDoc(
description.GroupName,
new Info()
{
Title = $"API {description.ApiVersion}",
Version = description.ApiVersion.ToString(),
Description = "Services for handling resource requests",
}
});
}
var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "API.xml");
c.IncludeXmlComments(filePath);
});