You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simple reproduction steps are to create an [ApiController] and set a [ControllerName(...)] attribute on it which overrides the controller's name to something else, example:
// simple setup with including xml commentsservices.AddSwaggerGen(c =>{c.SwaggerDoc("v1",newOpenApiInfo{Title="My API",Version="v1"});c.IncludeXmlComments(...,includeControllerXmlComments:true);});/// <summary>/// My test controller to prove bugs/// </summary>[ApiController][Route("api/test")][ControllerName("Test")]publicclassMyTestController:ControllerBase{/// <summary>/// Returns something else/// </summary>/// <returns></returns>[HttpGet]publicIActionResultIndex(){returnOk(new{Something="Hello",Else="World"});}}
The default SwaggerGeneratorOptions.TagsSelector uses the RouteValues["controller"] as the tag it puts on actions, but the XmlCommentsDocumentFilter.cs will create the tag using ControllerName which is the original/raw name (minus the Controller suffix if it exists).
This leads to ReDoc and Swagger UI to show an extra section with the raw controller name and the comment, and a separate section with the action actions.
Expected behavior would be that controller comments properly show up under the "Test" section.
The text was updated successfully, but these errors were encountered:
In Swashbuckle.AspNetCore.SwaggerGen v6.5.0
There appears to be a bug in XmlCommentsDocumentFilter.cs
Simple reproduction steps are to create an [ApiController] and set a [ControllerName(...)] attribute on it which overrides the controller's name to something else, example:
The default SwaggerGeneratorOptions.TagsSelector uses the RouteValues["controller"] as the tag it puts on actions, but the XmlCommentsDocumentFilter.cs will create the tag using ControllerName which is the original/raw name (minus the Controller suffix if it exists).
This leads to ReDoc and Swagger UI to show an extra section with the raw controller name and the comment, and a separate section with the action actions.
Expected behavior would be that controller comments properly show up under the "Test" section.
The text was updated successfully, but these errors were encountered: