Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Support .NET 8
Tracking issue to add support for net8.0.
This issue does not cover adding support for any new language features added as part of .NET 8 (or 7), such as required members (see #2555), new ASP.NET Core features etc. Those will be treated as separate feature requests.
Great to see a tracking issue for this! Congratulations on the new core team as well. Not sure if this is somewhat covered by any of the closed issues but probably worth to include at least to get the documentation updated once support lands.
"Build-time OpenAPI document generation with Swashbuckle isn't supported in .NET 8 and later. For a supported build-time alternative, see ASP.NET Core web API documentation with Swagger / OpenAPI. Run-time document generation is still supported in .NET 8." https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-8.0
Glad to see the progress here, let's follow it up together
Just to chime in, you can delete this comment if this is not relevant! 😄
Anyway, me and my college were trying to generate the swagger.json file from a dotnet8 project. Worked like a charm on my machine, but was always giving an error message when running
dotnet "tool" "run" "swagger" "tofile" "--output"
And it was always suggesting that we install dotnet7.
We tried to use homebrew to have 2 different versions at the same time but it didn't work. What did work, however, was removing all versions, folders and stuff from /usr/local/share/dotnet.
Then we installed, first, dotnet7SDK from microsoft (https://dotnet.microsoft.com/en-us/download/dotnet/7.0) and then we installed dotnet8SDK (https://dotnet.microsoft.com/en-us/download/dotnet/8.0) and everything worked like a charm!
Hope this helps!
Another way to workaround the need for .NET 7 when using the CLI tool is to set the following environment variable:
DOTNET_ROLL_FORWARD=LatestMajor
That will cause the tool to run with the .NET 8 runtime (doesn't guarantee it'll work, but I imagine it will).
Hi, I keep getting a different error:
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'IServiceProvider'.
In net7.0 everything works fine and the openapi.json file gets created during VS 2022 PostBuildEvent where I have the following code:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="dotnet tool restore"></Exec>
<Exec Command="dotnet tool run swagger tofile --output openapi.json $(TargetPath) v1"></Exec>
<Exec Command="dotnet tool run swagger tofile --output openapi-v2.json $(TargetPath) v2"></Exec>
</Target>
I tried using the environment variable DOTNET_ROLL_FORWARD=LatestMajor but it didn't work. :(
Can you please shed some light on what could be the issue? I cannot move my .NET Core APIs to .NET 8 because of this issue.
Thank you, P.
If the environment variable isn't working, all I can suggest for now to wait until #2799 is merged and then test it out with a version from our prerelease feed. If it then still doesn't work, we can look into it.
Thank you @martincostello. I shall wait as you suggest. Thank you!