Как добавить Swashbuckle AspNetCore XmlCommentsDocumentFilter - PullRequest
0 голосов
/ 09 июня 2018

Добавление 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);
});
...