refactor: Migrate livechat/users endpoints to OpenAPI with AJV validation
Closed
AM
6mo ago+201+201+012345678901234567890123456789-212-212-012345678901234567890123456789
Proposed changes
Migrates the livechat/users/:type and livechat/users/:type/:_id endpoints from the legacy addRoute() pattern to the new OpenAPI-compatible chained route pattern with inline AJV validation schemas.
Resolves: https://github.com/RocketChat/Rocket.Chat-Open-API/issues/150
Changes
apps/meteor/app/livechat/imports/server/rest/users.ts
- Replaced legacy
API.v1.addRoute()calls with the new chainedAPI.v1.get().post().get().delete()pattern - Added inline AJV validation schemas for query params, request body, and responses (200/400/401/403)
- Used
ExtractRoutesFromAPI+declare moduleaugmentation for type extraction - All 4 endpoints migrated:
GET /livechat/users/:type,POST /livechat/users/:type,GET /livechat/users/:type/:_id,DELETE /livechat/users/:type/:_id
packages/rest-typings/src/v1/omnichannel.ts
- Removed parameterized path types (
/livechat/users/${string},/livechat/users/${string}/${string}) that were previously in the sharedEndpointsinterface - Kept concrete path aliases (e.g.,
/livechat/users/agent) for client-sideuseEndpoint()compatibility
.changeset/migrate-livechat-users-openapi.md
- Added changeset with
minorbump for@rocket.chat/meteorand@rocket.chat/rest-typings
Test results
Summary by CodeRabbit
-
New Features
- OpenAPI-backed request/response validation for livechat user endpoints.
- Separate manager and user routes with create, list, fetch-by-id, and delete actions; create now accepts a simple username payload.
-
Refactor
- Routes reorganized for clearer manager/user separation, improved pagination, filtering, and sensible defaults.
- Stronger authorization checks and clearer error responses; single-user fetch may return null when not found.