docs(controllerClass, config)
Applies Swagger decorators to a controller class from outside its file, as a side effect on import.
Signature
Call it at the top level of a *.controller.docs.ts file, where it runs as a side effect on import.
Type-safety
Fully type-safe: config.methods only accepts keys that exist on the controller class. Typos are caught at compile time.
ts
docs(UsersController, {
classDecorators: [ApiTags('users')],
methods: {
findAll: [...], // ✔ exists on UsersController
typoMethod: [...], // ✖ TypeScript error
},
});Config fields
config.classDecorators:ClassDecorator[], applied to the class constructor (e.g.,ApiTags,ApiBearerAuth).config.methods:Partial<Record<keyof T, MethodDecorator[]>>, decorator arrays keyed by method name, applied in order.config.group:string, logical group name for ReDoc'sx-tagGroupsextension.config.tags:string[], tag names associated with thegroup. Must match what you pass toApiTags().
Runtime behavior
Non-existent method key
If a method key doesn't exist on the controller at runtime, a warning is logged and that entry is skipped, but the rest of the docs file is still applied.