chore: migrate rooms.leave endpoint to new OpenAPI pattern with AJV validation#38957
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 1605bcc The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe rooms.leave endpoint was migrated from the legacy API.v1.addRoute implementation to an OpenAPI-style route using AJV request validation, with a new RoomsLeave union type, compiled validator, and the route integrated into the existing roomEndpoints chain. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant APIv1 as API.v1 rooms.leave
participant AJV as AJV Validator
participant Rooms as Room Resolver
participant Users as User Service
participant Method as leaveRoomMethod
Client->>APIv1: POST /api/v1/rooms.leave {roomId|roomName}
APIv1->>AJV: validate(body)
AJV-->>APIv1: valid / invalid
alt valid
APIv1->>Rooms: resolve room by id or name
Rooms-->>APIv1: room (or not found)
APIv1->>Users: fetch user by request auth
Users-->>APIv1: user (or not found)
APIv1->>Method: leaveRoomMethod(user, room)
Method-->>APIv1: result
APIv1-->>Client: 200 { success: true }
else invalid
APIv1-->>Client: 400 validation error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@ggazzo 👍 |
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Migrated rooms.leave endpoint to new OpenAPI pattern with AJV validation |
There was a problem hiding this comment.
you need to add the rest-types, because you have done changes there
'@rocket.chat/rest-typings': patch…rifieddanny/Rocket.Chat into refactor/migrate-rooms-leave-endpoint
|
/jira ARCH-1935 |
…rifieddanny/Rocket.Chat into refactor/migrate-rooms-leave-endpoint
|
@ggazzo just made the changeset changes from patch to minor |
|
If you keep syncing with develop, I can't add it to the queue. |
|
Ohh alright, noted moving forward 🫡 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #38957 +/- ##
===========================================
+ Coverage 70.64% 70.67% +0.03%
===========================================
Files 3189 3189
Lines 112716 112716
Branches 20413 20434 +21
===========================================
+ Hits 79632 79667 +35
+ Misses 31040 31007 -33
+ Partials 2044 2042 -2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
Migrates the
rooms.leaveendpoint from the legacyAPI.v1.addRoutepattern 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:
API.v1.addRoutewith chained.post()forrooms.leaveanyOfconstraint supportingeither
roomIdorroomNamepackages/rest-typings/src/v1/rooms.tssince it is now auto-generated via
ExtractRoutesFromAPISwagger UI — endpoint documented at
/api-docs/:400 response — validation and business logic working correctly:
Steps to test or reproduce
yarn devhttp://localhost:3000/api-docs/X-Auth-TokenandX-User-IdPOST /api/v1/rooms.leave{ "roomName": "general" }{}to confirm 400 validation errorFurther comments
Follows the same migration pattern established in #35995 (rooms.favorite).
Summary by CodeRabbit
Task: ARCH-1987