简体   繁体   English

在 Swagger 中显示不同的 controller 名称

[英]Display different controller name in Swagger

I would like to change the name of the controller in Swagger.我想在 Swagger 中更改 controller 的名称。

I'm using .NET 5, Swashbuckle AspNetCore v6.3.1 and have this Startup code:我正在使用 .NET 5,Swashbuckle AspNetCore v6.3.1 并具有以下启动代码:

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

Controller: 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:它似乎运行良好,除了我仍然可以看到旧的 controller 名称,在 Swagger 中没有列出任何内容:

在此处输入图像描述

How can I remove the old controller name from Swagger?如何从 Swagger 中删除旧的 controller 名称?

By removing this comment above my controller, I was able to remove the old controller name from the swagger UI:通过删除我的 controller 上方的此评论,我能够从 swagger UI 中删除旧的 controller 名称:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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