簡體   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