Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(plugins): document the validation 400 on plugin config routes
Yudhi Armyndharisd1e37d14362b
diff --git a/src/modules/plugins/plugins.controller.spec.ts b/src/modules/plugins/plugins.controller.spec.tsindex 7569827c8..e44cfa29c 100644--- a/src/modules/plugins/plugins.controller.spec.ts+++ b/src/modules/plugins/plugins.controller.spec.ts@@ -59,4 +59,16 @@ describe('PluginsController.install() OpenAPI responses', () => {) as Record<string, unknown>;expect(Object.keys(responses)).toContain('413');});++ // The global ValidationPipe refuses an invalid body, or one carrying an undeclared field, with a 400.+ it.each(['updateConfig', 'updateSessionConfig', 'updateSessions'] as const)(+ 'declares the validation 400 on %s',+ handler => {+ const responses = (Reflect.getMetadata(+ 'swagger/apiResponse',+ Object.getOwnPropertyDescriptor(PluginsController.prototype, handler)!.value as object,+ ) ?? {}) as Record<string, { description?: string }>;+ expect(responses['400']?.description).toMatch(/validation/i);+ },+ );});diff --git a/src/modules/plugins/plugins.controller.ts b/src/modules/plugins/plugins.controller.tsindex d5f6549f2..ef908522a 100644--- a/src/modules/plugins/plugins.controller.ts+++ b/src/modules/plugins/plugins.controller.ts@@ -134,6 +134,7 @@ export class PluginsController {@RequireUnscopedKey()@ApiOperation({ summary: 'Update plugin configuration' })@ApiResponse({ status: 200, description: 'Plugin configuration updated', type: PluginActionResponseDto })+ @ApiResponse({ status: 400, description: 'Validation failed, or the body carries a field the DTO does not declare.' })@ApiResponse({ status: 404, description: 'Plugin not found' })updateConfig(@Param('id') id: string, @Body() configDto: PluginConfigDto): { success: boolean; message: string } {return this.pluginsService.updateConfig(id, configDto.config);@@ -165,7 +166,7 @@ export class PluginsController {@RequireRole(ApiKeyRole.ADMIN)@ApiOperation({ summary: 'Set a plugin config override for a specific session (empty = clear it)' })@ApiResponse({ status: 200, description: 'Per-session plugin configuration updated', type: PluginActionResponseDto })- @ApiResponse({ status: 400, description: 'Plugin is global (not session-scoped)' })+ @ApiResponse({ status: 400, description: 'Plugin is global (not session-scoped), or the body failed validation' })@ApiResponse({ status: 404, description: 'Plugin not found' })updateSessionConfig(@Param('id') id: string,@@ -180,7 +181,7 @@ export class PluginsController {@RequireUnscopedKey()@ApiOperation({ summary: "Set which sessions a session-scoped plugin is activated for (['*'] = all)" })@ApiResponse({ status: 200, description: 'Plugin session activation updated', type: PluginDto })- @ApiResponse({ status: 400, description: 'Plugin is global (not session-scoped)' })+ @ApiResponse({ status: 400, description: 'Plugin is global (not session-scoped), or the body failed validation' })@ApiResponse({status: 403,description: