简体   繁体   中英

Display different controller name in Swagger

I would like to change the name of the controller in Swagger.

I'm using .NET 5, Swashbuckle AspNetCore v6.3.1 and have this Startup code:

 public void ConfigureServices(IServiceCollection services) { // code omitted for brevity services.AddSwaggerGenNewtonsoftSupport(); services.AddSwaggerGen(x => x.EnableAnnotations()); }

Controller:

 [Route("v1/taggroups")] [ApiController] public class ProfileGroupTypesController: ControllerBase { [HttpPost] [SwaggerOperation(OperationId = "Add Tag Group", Tags = new[] { "TagGroups" })] public IActionResult CreateProfileGroupType([FromBody] CreateProfileGroupTypeRequest request) { } }

It seems to work well, except I can still see the old controller name with nothing listed under it in Swagger:

在此处输入图像描述

How can I remove the old controller name from Swagger?

By removing this comment above my controller, I was able to remove the old controller name from the swagger UI:

 /// <summary> /// ProfileGroupTypes Controller // REMOVE THIS /// </summary> [Route("v1/taggroups")] [ApiController] public class ProfileGroupTypesController: ControllerBase {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM