在Swagger中显示不同的控制器名称
我想用大招牌更改控制器的名称。
我正在使用.net 5,swashbuckle aspnetcore v6.3.1,并具有此启动代码:
public void ConfigureServices(IServiceCollection services)
{
// code omitted for brevity
services.AddSwaggerGenNewtonsoftSupport();
services.AddSwaggerGen(x => x.EnableAnnotations());
}
控制器:
[Route("v1/taggroups")]
[ApiController]
public class ProfileGroupTypesController : ControllerBase
{
[HttpPost]
[SwaggerOperation(OperationId = "Add Tag Group", Tags = new[] { "TagGroups" })]
public IActionResult CreateProfileGroupType([FromBody] CreateProfileGroupTypeRequest request)
{
}
}
它似乎很好,除了我仍然可以看到旧的控制器名称,swagger下没有列出任何内容:
如何从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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过在控制器上方删除此评论,我能够从Swagger UI中删除旧的控制器名称:
By removing this comment above my controller, I was able to remove the old controller name from the swagger UI: