Search code examples
swaggerswagger-uiswashbuckleswagger-codegen

Update to Swashbuckle.AspNetCore 3.0 does not group by tag anymore


I was using [SwaggerOperation(Tags = new[] { "GroupA" })] to group my actions within a controller in Swagger UI.

After updating to 3.0 this is not taken into account anymore and is only grouped by controller name.

The "changed" tag names from the attribute are also not generated into the Swagger JSON/YAML anymore, there is just the controller name as a tag.

I was not able to find a hint in the release notes regarding breaking changes of this behavior.

Any insights about behavioral changes and/or how I could restore it would be greatly appreciated.


Solution

  • So all of this is well documented in the release notes, you just shouldn't be in a rush while reading it.

    What I did not mention in my question was that I needed to install Swashbuckle.AspNetCore.Annotations to get [SwaggerOperation] back (it has been separated).

    And these now need to be actively enabled via:

    services.AddSwaggerGen(c =>
    {
       ...
    
       c.EnableAnnotations();
    });
    

    From the release notes:

    Updates to annotations: To continue using the swagger-specific annotations, you'll need to explicitly install and enable the new Swashbuckle.AspNetCore.Annotations package as described here.

    "here" brings you exactly to the place where this step is described:

    https://github.com/domaindrivendev/Swashbuckle.AspNetCore#swashbuckleaspnetcoreannotations