Tag groups + Redoc
Register groups via docs({ group, tags }) and attach the x-tagGroups extension to the document before serving.
Registering groups
users.controller.docs.ts / roles.controller.docs.ts
docs(UsersController, {
classDecorators: [ApiTags('users')],
group: 'Administration',
tags: ['users'],
});
docs(RolesController, {
classDecorators: [ApiTags('roles')],
group: 'Administration',
tags: ['roles'],
});group and tags in docs() are optional. tags should match what you already pass to ApiTags(): nestjs-docfy doesn't call ApiTags for you, it only uses those names to build the x-tagGroups mapping. Multiple docs() calls can contribute to the same group; tags are merged and deduplicated.
Attaching to the document
main.ts
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { attachTagGroups } from 'nestjs-docfy';
const document = SwaggerModule.createDocument(app, new DocumentBuilder().build());
SwaggerModule.setup('api', app, attachTagGroups(document));Call attachTagGroups() after SwaggerModule.createDocument() and before SwaggerModule.setup(). If no controller registered a group, the function is a no-op and returns the document unchanged. Redoc reads x-tagGroups natively and renders the grouped sidebar. Details in Tag groups.