Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(session): declare the 400 and 502 responses routes return
Yudhi Armyndharis4a2b1f1c66d3
diff --git a/src/modules/session/session.controller.spec.ts b/src/modules/session/session.controller.spec.tsindex d6092791b..36d931ef6 100644--- a/src/modules/session/session.controller.spec.ts+++ b/src/modules/session/session.controller.spec.ts@@ -592,3 +592,17 @@ describe('SessionController.start() OpenAPI responses', () => {expect(Object.keys(responses)).toContain('504');});});++describe('SessionController OpenAPI error responses', () => {+ it.each([+ ['create', '400'],+ ['findAll', '400'],+ ['forceKill', '502'],+ ])('%s declares %s', (method, status) => {+ const responses = Reflect.getMetadata(+ 'swagger/apiResponse',+ Object.getOwnPropertyDescriptor(SessionControllerClass.prototype, method)!.value as object,+ ) as Record<string, unknown>;+ expect(Object.keys(responses)).toContain(status);+ });+});diff --git a/src/modules/session/session.controller.ts b/src/modules/session/session.controller.tsindex d0c4d7091..68889cf6c 100644--- a/src/modules/session/session.controller.ts+++ b/src/modules/session/session.controller.ts@@ -98,6 +98,7 @@ export class SessionController {description:'Key lacks the OPERATOR role, is restricted to specific sessions, or set proxyUrl without the ADMIN role',})+ @ApiResponse({ status: 400, description: 'Validation failed, or the body carries a field the DTO does not declare.' })@ApiResponse({ status: 409, description: 'Session name already exists' })async create(@Body() dto: CreateSessionDto, @CurrentApiKey() apiKey?: ApiKey): Promise<SessionResponseDto> {// A session proxy carries the session's egress, including the gateway's fetches of caller-supplied@@ -131,6 +132,7 @@ export class SessionController {'Return only the session with exactly this name (case-sensitive); no match returns an empty array. ' +'An empty value or a repeated key is rejected with 400.',})+ @ApiResponse({ status: 400, description: '`name` is empty or repeated.' })async findAll(@CurrentApiKey() apiKey?: ApiKey,@Query('limit') limit?: string,@@ -439,6 +441,14 @@ export class SessionController {})@ApiResponse({ status: 400, description: 'Session is not started' })@ApiResponse({ status: 404, description: 'Session not found' })+ @ApiResponse({+ status: 502,+ description:+ 'Session was stopped locally, but the engine force-kill did not complete (the force-destroy ' ++ 'threw or timed out, so the engine process may still be running). The body carries ' ++ "`code: 'SESSION_FORCE_KILL_INCOMPLETE'`; the status is settled to `disconnected` and no " ++ 'success audit is written. Restart the node to reap a leaked process.',+ })async forceKill(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {const session = await this.sessionService.forceKill(id);await this.auditService.logInfo(AuditAction.SESSION_FORCE_KILLED, {