繁体   English   中英

在 Swagger 中显示不同的 controller 名称

[英]Display different controller name in Swagger

我想在 Swagger 中更改 controller 的名称。

我正在使用 .NET 5,Swashbuckle AspNetCore v6.3.1 并具有以下启动代码:

 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) { } }

它似乎运行良好,除了我仍然可以看到旧的 controller 名称,在 Swagger 中没有列出任何内容:

在此处输入图像描述

如何从 Swagger 中删除旧的 controller 名称?

通过删除我的 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