Search code examples
c#asp.net-core-webapiopenapiswashbuckle.net-9.0

How to group controller using OpenAPI and Scalar API documentations


I have an ASP.NET Core 9 Web API application. By default, .NET9 doesn't use Swashbuckle anymore. To generate API documentations I'm using Microsoft OpenAPI documents and Scalar.

It works fine. I need to group all endpoints into smaller groups. For example, User, Order etc. User group will contain authentication controller, changing profile profile controller and Order group will contain order controller and payment controller.

Is it possible to group those endpoints?


Solution

  • Use the Tags attribute. I've found Scalar will group the methods under those tags perfectly. Something similar to:

    [EndpointDescription("Retrieve a paged list of people based on a set of filters")]
    [EndpointSummary("List People")]
    [Tags("People")]
    [HttpGet("people")]
    [ProducesResponseType<PagedResultDto<PersonDto>>(StatusCodes.Status200OK, "application/json")]
    public async Task<IActionResult> GetPeople([FromQuery] GetPeopleInputDto inputDto)
    { ... }
    

    enter image description here