Swashbuckle.aspnetcore: SwaggerGen doesn't work and no any error after upgrade of asp.net core pakcages

Created on 9 Jan 2019  路  7Comments  路  Source: domaindrivendev/Swashbuckle.AspNetCore

Hi all

Sorry, I can't provide exact repro steps, because entire SwaggerGen just stop working. Now what we did.

  1. We had project with asp.net core 2.0.1 packages. Swagger version is 2.9.0.
  2. We did upgrade to asp.net core 2.2.0. After that point swagger just stop working: we can open UI, it generate swagger.json, but no any end point inside (we have "No operations defined in spec!" message)

Here is list of packages before upgrade:

<PackageReference Include="AsyncFriendlyStackTrace" Version="1.6.0" />
    <PackageReference Include="AutoMapper" Version="8.0.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
    <PackageReference Include="Microsoft.AspNet.WebApi.OData" Version="5.7.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.0.3" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="2.0.0" />
    <PackageReference Include="Microsoft.Graph" Version="1.12.0" />
    <PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.4.1" />
    <PackageReference Include="Microsoft.ServiceFabric" Version="6.0.232" />
    <PackageReference Include="Microsoft.ServiceFabric.Actors" Version="2.8.232" />
    <PackageReference Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" Version="2.8.232" />
    <PackageReference Include="Microsoft.ServiceFabric.Data" Version="2.8.232" />
    <PackageReference Include="Microsoft.ServiceFabric.Services" Version="2.8.232" />
    <PackageReference Include="Microsoft.ServiceFabric.Services.Remoting" Version="2.8.232" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.1" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
    <PackageReference Include="StackTraceFormatter.Source" Version="1.1.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.Examples" Version="2.9.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="2.4.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="2.4.0" />
    <PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
    <PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />

And here is a new one:

<PackageReference Include="AsyncFriendlyStackTrace" Version="1.6.0" />
    <PackageReference Include="AutoMapper" Version="8.0.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
    <PackageReference Include="Microsoft.AspNet.WebApi.OData" Version="5.7.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="2.2.0" />
    <PackageReference Include="Microsoft.Graph" Version="1.12.0" />
    <PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.4.2" />
    <PackageReference Include="Microsoft.ServiceFabric" Version="6.4.624" />
    <PackageReference Include="Microsoft.ServiceFabric.Actors" Version="3.3.624" />
    <PackageReference Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" Version="3.3.624" />
    <PackageReference Include="Microsoft.ServiceFabric.Data" Version="3.3.624" />
    <PackageReference Include="Microsoft.ServiceFabric.Services" Version="3.3.624" />
    <PackageReference Include="Microsoft.ServiceFabric.Services.Remoting" Version="3.3.624" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
    <PackageReference Include="StackTraceFormatter.Source" Version="1.1.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.Examples" Version="2.9.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="2.4.0" />
    <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="2.4.0" />
    <PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
    <PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />

There are no any error messages n the Debug, nothing. I also did try to upgrade SwaggerGen itself (latest stable version), but no luck, same behavior. No code was changed, just packages (well, except few attributes for Service Fabric, not related).
So, my first suggestion is to add some verbose logging for the SwaggerGen, because for the moment it's a black box: no any output for what it doing.
The bug itself is that SwaggerGen doesn't work itself after the simple upgrade. How can I troubleshoot that?

Most helpful comment

I had the same issue, try adding an [ApiController] attribute at the top of your controllers, that's what I think I did to fix it. It seems to be a change in the .Net Core ApiExplorer library.

If that doesn't work put a breakpoint in Startup.Configure and check you provider (IApiVersionDescriptionProvider) to see if there is any API definition in there.

All 7 comments

I had the same issue, try adding an [ApiController] attribute at the top of your controllers, that's what I think I did to fix it. It seems to be a change in the .Net Core ApiExplorer library.

If that doesn't work put a breakpoint in Startup.Configure and check you provider (IApiVersionDescriptionProvider) to see if there is any API definition in there.

I also just noticed that the package Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer is out of date, I have version 3.1.0 in my projects. That may also have something to do with it.

I am also using version 4.0.1 of the Swashbuckle stuff, I notice you are on an older version, not sure if that older version is compatible with .Net Core 2.2.

Oh, I thought I closed this one. You must use 2.x version of the Microsoft.AspNetCore.Mvc.Versioning and Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer

Oh, I thought I closed this one. You must use 2.x version of the Microsoft.AspNetCore.Mvc.Versioning and Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer

Any idea why? We're having these versioning issues in our api: https://github.com/Microsoft/aspnet-api-versioning/issues/363
So we'd like to update the Versioning packages

Same problem here when using AspNetCore.Mvc.Versioning 3.0.0 it works, but upgrading to any version higher breaks the swagger generation.

Due to the issues w/ older AspNetCore.Mvc.Versioning and .NET Core 2.2 Endpoint Routing support I think that the stance of only using 2.X of this library is a little rough...

Same problem here when using AspNetCore.Mvc.Versioning 3.0.0 it works, but upgrading to any version higher breaks the swagger generation.

Due to the issues w/ older AspNetCore.Mvc.Versioning and .NET Core 2.2 Endpoint Routing support I think that the stance of only using 2.X of this library is a little rough...

What version of Swagger are you using? I had this same issue with AspNetCore 2.2, AspNetCore.Mvc.Versioning 3.1.2, AspNetCore.Mvc.Versioning.ApiExplorer 3.2.0, and Swashbuckle 4.0.1 But I was able to fix it by adding the [ApiController] attributes to my controllers

Any idea why? We're having these versioning issues in our api: Microsoft/aspnet-api-versioning#363
So we'd like to update the Versioning packages

Because versioning dramatically changed in asp.net 3 and you can't mix v3 and v2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flipchart picture flipchart  路  4Comments

TimmyGilissen picture TimmyGilissen  路  3Comments

NinoFloris picture NinoFloris  路  3Comments

engelhardtda picture engelhardtda  路  3Comments

alasvant picture alasvant  路  3Comments