-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrading to ASP.NET Core 2.0 Preview 2 breaks Swagger UI #438
Comments
The exception looks like it comes from the static files middleware rather than Swashbuckle. Have you tried specifically adding a reference to the StaticFiles package to ensure you have the latest pinned? There's all sorts of weird stuff that happens when you try to mix release with preview bits. Happened when they were first coming out with netcore also. Work in progress that has breaking changes they may or may not keep in the next release... Painful. I'd look at all the packages Swashbuckle references and manually add them all to my project. Ensure they're the preview versions. That will force the latest to be used. If it still doesn't work I'd recommend debugging into Swashbuckle to at least get an exact location of where it's exploding. I'm sure when .NET Core 2 is closer to stable the will be a better compatibility story. Until then, it'd be super helpful to get folks trying out the bleeding edge bits to help with the troubleshooting, too. |
Hi @tillig, Explicitly adding a NuGet reference to StaticFiles preview2 worked. Thanks very much for your help. The following are the package references that will make preview 2 work with Swagger UI for anyone who Googles their way to this issue:
|
I did not experienced that with latest ASP.NET Core 2.0 packages from CI |
I had the same issue and the solution for me was to install the Microsoft.AspNetCore.StaticFiles Nuget package. |
Aetherix, thanks a lot... it's fixed my problem. |
I had all the same, uninstall/reinstall of Swagger fixed me. |
I think it makes sense that the "Swashbuckle.AspNetCore" NuGet package has an explicit dependency on "Microsoft.AspNetCore.StaticFiles". |
Adding "Microsoft.AspNetCore.StaticFiles" explicitly didn't work for me. Uninstalling "Swashbuckle.AspNetCore" and reinstalling it DID fix the problem. |
What did the trick for me:
|
Aetherix, like wsun4ipipeline your solution did the trick. It fixed my problem. |
For me, installing |
Remember to add: public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
} |
I'm still struggling with this issue, any other ideas? Thanks. |
Hi @tillig, By adding staticFiles nuget it worked for me.Thanks for your help. |
Thanks Guys, Installing **
** worked for me. |
I have installed Swashbuckle.AspNetCore.SwaggerUI and am still having this issue. I believe we are off the preview of ASP.NET Core 2.0 though right? |
Thanks Hikalkan. Installing Microsoft.AspNetCore.StaticFiles worked for me on vs on mac os high sierra |
Let me tell that as polite as possible: I FUCKING HATE THAT FUCKING TRANSITIVE NUGET REFERENCES! [1] Please anyone tell me which NuGet/VS-Tool will show me that there are old packages (like StaticFiles 1.0.4) which could be updated. Or how I can change that silly "most minor version" preference of transitive package restore. Ranting some more: In this special case (aspnetcore) I could use Microsoft.AspNetCore.All if it wasn't tied to netcoreapp2.0 -- I am using full .net framework so I cannot use this package. [1] Of course I don't like the old style either: Where 1001 packages are listed in packages.config and no one knows why any of them is listed there. |
@springy76 transitive nuget references aren't the problem here. You're just experiencing a version mismatch and a breaking change. This is a just an honest incompatiblity and nothing saves you here. Here's what could have been done and what still could be done to make this issue fail better (becuse it'll still fail it'll just fail better). ASP.NET 1.x should set upperbounds on our packages for the next major version. If we did that, you'd get an error that StaticFiles 1.0.x cannot function with ASP.NET Core 2.x. |
Same here, just like vpaulino - after upgrading to 2.1 build was broken with the same runtime exception:
It turns out that the ctor really ceased to exist. It now takes the new StringSegment instead of plain String, see https://docs.microsoft.com/en-us/dotnet/api/microsoft.net.http.headers.entitytagheadervalue?view=aspnetcore-2.1 . While StringSegment and String are convertible, that's only during compilation. On the assembly side the signature of the constructor has changed, so without recompiling it cannot just be wired up. I think it all boils down to something in your project pulling the static-files in 2.0 instead of 2.1? |
Back on topic - yup - Swagger.UI 1.1.0 bases on StaticFiles 1.0.4 and that collides with asp-core 2.1 that upgrades that to static-files-2.1 which has the new construtor style. Well.. that ref wasn't updated for a long time (--"). However, even after updating Swagger to the newest 2.5.0, it still depends on StaticFiles 1.0.4 and still crashes. So far I've NOT managed to force my projects to use the old library by
|
FYI: I cloned SwaggerUI, updated the ref to 2.1.1, recompiled, and everything works fine. |
Swashbuckle.AspNetCore v3 still has this problem. Any workarounds (apart from what @quetzalcoatl did)? |
What I had to do for V2 and V3 of Swagger was to add a NuGet reference to Microsoft.AspNetCore.StaticFiles 2.1.1. Hope this help! |
After upgrading to .NET Core 2.0 Preview 2 Navigating to the default /Swagger route results in the following exception:
Steps to reproduce
Change TargetFramework to netcoreap2.0. Manually edit the project file to update the packages as follows so the site runs:
Configure Swagger as per the documentation in this repo's README.md
Expected outcome
The Swagger UI for the default API in the web project
Actual outcome
The Exception above
The text was updated successfully, but these errors were encountered: