Search code examples
c#asp.net-core-webapinswag

NSwag change controller description


I want to change controller description of NSwag UI in .Net Core. I am using latest version (13.8.1). How to achieve this?

enter image description here

From the image above, I want to rename the title RefUserLocation to User Location. But doesn't change the endpoint itself where users are still able to access to api/refuserlocation


Solution

  • Add [OpenApiTag("RenameName")] to your controller like below:

    using NSwag.Annotations;
    
    [Route("api/[controller]")]
    [ApiController]
    [OpenApiTag("User Location")]
    public class RefUserLocationController : ControllerBase
    {...}
    

    Result: enter image description here

    Note:

    I use NSwag.AspNetCore version 13.8.2.So the SwaggerTag is obsolete,if you used the older version of nswag,you could use [SwaggerTag("User Location")].