chore(rest): migrate /api/v1/users.autocomplete to OpenAPI endpoint definition

Closed
YA
6mo ago
+111-33

Migrates the users.autocomplete REST API endpoint from the legacy API.v1.addRoute pattern to the new chained API.v1.get() pattern with AJV query and response schema validation and OpenAPI documentation support.

Endpoints migrated

EndpointMethodOld PatternNew Pattern
users.autocompleteGETaddRoute.get() chained

Architectural changes

  • Replaced legacy API.v1.addRoute('users.autocomplete', ...) with the new chained .get('users.autocomplete', ...) method
  • Added AJV query schema validation for the selector parameter
  • Added 400 and 401 error response schemas using validateBadRequestErrorResponse and validateUnauthorizedErrorResponse
  • Added AJV 200 response schema for the returned autocomplete users list
  • Ensured strict validation with additionalProperties: false in the query schema
  • Preserved the existing permission checks and selector validation logic using isValidQuery

Files changed

  • apps/meteor/app/api/server/v1/users.ts β€” Main migration
  • packages/rest-typings/src/v1/users.ts β€” Removed the old manual TypeScript typing for users.autocomplete since endpoint types are now derived from the AJV schema
  • .changeset/migrate-users-autocomplete-openapi.md β€” Changeset entry

Related project

This continues the REST API migration effort described in the GSoC 2026 project: Replace old REST API definitions with the new API pattern.

cc @diego-sampaio @ggazzo

This PR is part of the ongoing REST API migration effort tracked in RocketChat/Rocket.Chat-Open-API#150

Summary by CodeRabbit

  • New Features
    • Enhanced users.autocomplete REST endpoint with richer, permission-aware results, stricter request/response validation, and preserved routing behavior.
  • Documentation
    • Added migration guidance and OpenAPI documentation for the users.autocomplete endpoint and its new API pattern.