chore: migrate rooms.leave endpoint to new OpenAPI pattern with AJV validation
Merged
VE
7mo ago+68+68+01234567890123456789-22-22-01234567890123456789
Proposed changes (including videos or screenshots)
Migrates the rooms.leave endpoint from the legacy API.v1.addRoute
pattern to the new OpenAPI-compliant format using AJV schema validation,
continuing the REST API migration effort.
Tracked in: RocketChat/Rocket.Chat-Open-API#150
Key changes:
- Replaced
API.v1.addRoutewith chained.post()forrooms.leave - Added declarative AJV body schema with
anyOfconstraint supporting
eitherroomIdorroomName - Added explicit response schemas for 200, 400, and 401 status codes
- Removed manually written type from
packages/rest-typings/src/v1/rooms.ts
since it is now auto-generated viaExtractRoutesFromAPI - Added changeset file
- Business logic unchanged
Swagger UI — endpoint documented at /api-docs/:
400 response — validation and business logic working correctly:
Steps to test or reproduce
- Run the server locally with
yarn dev - Navigate to
http://localhost:3000/api-docs/ - Authorize with
X-Auth-TokenandX-User-Id - Find
POST /api/v1/rooms.leave - Execute with valid body:
{ "roomName": "general" } - Execute with empty body
{}to confirm 400 validation error
Further comments
Follows the same migration pattern established in #35995 (rooms.favorite).
Summary by CodeRabbit
- Chores
- Migrated the rooms.leave API to a new validated endpoint for more robust request handling and clearer error responses.
- Documentation
- Added a release changeset noting the patch bump and the endpoint migration.