Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(automation): declare the 400 the rule update route returns
Yudhi Armyndharis908f43b932c7
diff --git a/src/modules/automation/automation-rule.controller.spec.ts b/src/modules/automation/automation-rule.controller.spec.tsindex ad5c0fb11..e3e680c33 100644--- a/src/modules/automation/automation-rule.controller.spec.ts+++ b/src/modules/automation/automation-rule.controller.spec.ts@@ -112,6 +112,14 @@ describe('AutomationRuleController', () => {await expect(controller.findOne('s1', 'rule-404')).rejects.toBe(error);});+ it.each(['create', 'update'] as const)('declares the validation 400 on %s', handler => {+ const responses = (Reflect.getMetadata(+ 'swagger/apiResponse',+ Object.getOwnPropertyDescriptor(AutomationRuleController.prototype, handler)?.value as object,+ ) ?? {}) as Record<string, unknown>;+ expect(Object.keys(responses)).toContain('400');+ });+it('remove propagates not-found rejections unmapped', async () => {const error = new NotFoundException('Automation rule rule-404 not found');service.remove.mockRejectedValue(error);diff --git a/src/modules/automation/automation-rule.controller.ts b/src/modules/automation/automation-rule.controller.tsindex 1b68b5930..01500bc64 100644--- a/src/modules/automation/automation-rule.controller.ts+++ b/src/modules/automation/automation-rule.controller.ts@@ -15,7 +15,7 @@ export class AutomationRuleController {@ApiOperation({ summary: 'Create an autoreply rule' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiResponse({ status: 201, description: 'Rule created.', type: AutomationRuleResponseDto })- @ApiResponse({ status: 400, description: 'Invalid rule (bad conditions, over-limit text).' })+ @ApiResponse({ status: 400, description: 'Invalid rule (bad conditions, over-limit text, out-of-range cooldown).' })@ApiResponse({ status: 404, description: 'No session with this id.' })async create(@Param('sessionId') sessionId: string,@@ -58,6 +58,7 @@ export class AutomationRuleController {@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'ruleId', description: 'Rule ID' })@ApiResponse({ status: 200, description: 'Updated rule.', type: AutomationRuleResponseDto })+ @ApiResponse({ status: 400, description: 'Invalid rule (bad conditions, over-limit text, out-of-range cooldown).' })@ApiResponse({ status: 404, description: 'No such rule in this session.' })async update(@Param('sessionId') sessionId: string,