attachTagGroups(document)
为 Swagger 文档添加 x-tagGroups 扩展,内容来自通过 docs({ group, tags }) 注册的分组。
用法
在 SwaggerModule.createDocument() 之后、SwaggerModule.setup() 之前调用它。如果没有任何分组被注册,文档会原样返回。完整示例见 标签分组。
main.ts
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { attachTagGroups } from 'nestjs-docfy';
const config = new DocumentBuilder().setTitle('My API').build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, attachTagGroups(document));