unchase / Unchase.Swashbuckle.AspNetCore.Extensions

:hammer: A library contains a bunch of extensions (filters) for Swashbuckle.AspNetCore.
https://www.nuget.org/packages/Unchase.Swashbuckle.AspNetCore.Extensions
Apache License 2.0
115 stars 16 forks source link

Compatible with ASP.NET Core 6? #23

Closed lonix1 closed 1 year ago

lonix1 commented 2 years ago

Hi @unchase

Do you know if this library works with v6?

I upgraded my project from v5 to v6. It was working in v5. But this does not work anymore:

options.AddEnumsWithValuesFixFilters(services, o => {
  o.IncludeDescriptions = true;
  o.DescriptionSource = DescriptionSources.XmlComments;
  o.IncludeXmlCommentsFrom(path);
});

The error is:

System.InvalidOperationException in Microsoft.AspNetCore.dll: 'Cannot modify ServiceCollection after application is built.'

Do you use this library successfully with v6?

lonix1 commented 2 years ago

I think the problem is here. But I don't know why it worked in v5 but not v6.

andreireinus commented 2 years ago

I used this way, and it worked for me.

builder.Services.AddSwaggerGen(options =>
{
    options.AddEnumsWithValuesFixFilters(null, enumsOptions =>
    {
        enumsOptions.XEnumNamesAlias = "x-enum-varnames";
    });
});
gebiWangshushu commented 2 years ago

https://www.cnblogs.com/xiaxiaolu/p/16247490.html worked