refactor: migrate rooms.delete endpoint to new API format

Merged
RO
7mo ago
+55-28

Description

This PR migrates the rooms.delete endpoint from the deprecated addRoute pattern to the new OpenAPI + AJV validation pattern, following the guidelines in apps/meteor/app/api/README.md.

Key Changes

  • Full Migration: Replaced deprecated API.v1.addRoute('rooms.delete', ...) with the chained API.v1.post('rooms.delete', ...) method.
  • Input Validation: Added body validation using ajv.compile<{ roomId: string }>() with JSON Schema — replaces the manual if (!roomId) runtime check.
  • Response Schemas: Added compiled AJV response validators for:
    • 200 — Success response ({ success: true })
    • 400 — validateBadRequestErrorResponse
    • 401 — validateUnauthorizedErrorResponse
  • Swagger Documentation: Response block in the route definition enables automatic OpenAPI spec generation at /api-docs/.
  • Typing Cleanup: Registered endpoint types via ExtractRoutesFromAPI<typeof roomDeleteEndpoint> into the RoomEndpoints union — removing the need for manual type definitions in @rocket.chat/rest-typings.

Why

The addRoute method and validateParams property are deprecated per the API README. The new format enables:

  • Automatic OpenAPI specification generation
  • Runtime response validation in test environments
  • Stronger TypeScript type inference via ExtractRoutesFromAPI
  • Structured input validation via body/query instead of validateParams

Testing & Verification

  • yarn turbo run typecheck --filter='@rocket.chat/meteor' — passes (0 errors)
  • yarn eslint:fix && yarn stylelint:fix — no issues
  • yarn lint — passes

ScreenShot of Swagger ui testing

Screenshot 2026-02-08 131325 Screenshot 2026-02-08 131351

Summary by CodeRabbit

  • Refactor
    • Room deletion flow reorganized to use a dedicated endpoint handler with standardized validation and response format.
  • Chores
    • Public API surface updated to reflect the new endpoint structure.
  • Tests
    • End-to-end tests updated to expect a standardized error shape when parameters are missing.
  • Impact
    • No user-facing functional changes; errors are returned in a clearer, consistent format.

COMM-144
Task: ARCH-2001