refactor: Migrate livechat/users endpoints to OpenAPI with AJV validation

Closed
AM
6mo ago
+201-212

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 chained API.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 module augmentation 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 shared Endpoints interface
  • Kept concrete path aliases (e.g., /livechat/users/agent) for client-side useEndpoint() compatibility

.changeset/migrate-livechat-users-openapi.md

  • Added changeset with minor bump for @rocket.chat/meteor and @rocket.chat/rest-typings

Test results

image

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.