refactor: migrate rooms.delete endpoint to new API format
Merged
RO
7mo ago+55+55+01234567890123456789-28-28-01234567890123456789
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 chainedAPI.v1.post('rooms.delete', ...)method. - Input Validation: Added
bodyvalidation usingajv.compile<{ roomId: string }>()with JSON Schema — replaces the manualif (!roomId)runtime check. - Response Schemas: Added compiled AJV response validators for:
200— Success response ({ success: true })400—validateBadRequestErrorResponse401—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 theRoomEndpointsunion — 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/queryinstead ofvalidateParams
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
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.