Skip to content

chore: migrate users.getStatus endpoint to new OpenAPI pattern with AJV validation#39482

Closed
Yashika-code wants to merge 29 commits intoRocketChat:developfrom
Yashika-code:chore/migrate-users-getStatus-openapi
Closed

chore: migrate users.getStatus endpoint to new OpenAPI pattern with AJV validation#39482
Yashika-code wants to merge 29 commits intoRocketChat:developfrom
Yashika-code:chore/migrate-users-getStatus-openapi

Conversation

@Yashika-code
Copy link
Copy Markdown
Contributor

@Yashika-code Yashika-code commented Mar 9, 2026

Proposed changes

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

Closes #34983

Endpoints migrated

Endpoint Method Old Pattern New Pattern
users.getStatus GET addRoute.get() .get() chained

Architectural changes

  • Replaced legacy API.v1.addRoute('users.getStatus', ...) with the new chained .get('users.getStatus', ...) method
  • Added AJV response schema for 200 response with status, _id, and connectionStatus fields
  • Added 401: validateUnauthorizedErrorResponse for unauthorized access handling
  • Wired up ExtractRoutesFromAPI + declare module for automatic type inference
  • Removed manual /v1/users.getStatus typing from rest-typings UsersEndpoints (now inferred from API registration via module augmentation)

Files changed

  • apps/meteor/app/api/server/v1/users.ts — Main migration
  • packages/rest-typings/src/v1/users.ts — Removed old manual typing

Related project

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

cc @diego-sampaio @ggazzo

Summary by CodeRabbit

  • New Features

    • Enhanced /api/v1/me endpoint with improved validation and error handling for user profile requests.
    • Updated users.getStatus endpoint with structured response validation and authentication.
  • Documentation

    • Added changelog entry documenting API endpoint updates and minor version changes.

- Replace legacy API.v1.addRoute with API.v1.get
- Add AJV response validation schema
- Export MeEndpoints using ExtractRoutesFromAPI
- Extend @rocket.chat/rest-typings Endpoints interface
- Enable OpenAPI/Swagger schema generation
Updated /api/v1/me endpoint: removed old @openapi block, added detected AJV schema and TypeScript interface, and cleaned up rest-typings imports.
@Yashika-code Yashika-code requested a review from a team as a code owner March 9, 2026 18:24
@Yashika-code Yashika-code requested a review from a team as a code owner March 9, 2026 18:24
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 9, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR has conflicts, please resolve them before merging
  • This PR is missing the 'stat: QA assured' label
  • This PR is not mergeable
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: f46a7a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Minor
@rocket.chat/rest-typings Minor
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models Patch
@rocket.chat/ui-contexts Major
@rocket.chat/web-ui-registration Major
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch
@rocket.chat/ui-client Major
@rocket.chat/media-calls Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/ui-avatar Major
@rocket.chat/ui-video-conf Major
@rocket.chat/ui-voip Major
@rocket.chat/core-typings Minor
@rocket.chat/apps Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

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

@Yashika-code Yashika-code changed the title Chore/migrate users get status openapi chore: migrate users.getStatus endpoint to new OpenAPI pattern with AJV validation Mar 9, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 00852fb7-bd87-497e-b13f-52da27f604eb

📥 Commits

Reviewing files that changed from the base of the PR and between f5f2374 and f46a7a3.

📒 Files selected for processing (7)
  • .changeset/v1-me-endpoint-update.md
  • apps/meteor/app/api/server/v1/misc.ts
  • apps/meteor/app/api/server/v1/users.ts
  • packages/core-typings/src/Ajv.ts
  • packages/rest-typings/src/index.ts
  • packages/rest-typings/src/v1/me.ts
  • packages/rest-typings/src/v1/users.ts

Walkthrough

The changes introduce AJV-based validation and OpenAPI schema support for the /api/v1/me and /api/v1/users.getStatus endpoints. Updates include new type definitions (IMeResponse, MeParams), validation schemas, error handlers, and route configurations across the REST API, core typings, and type definitions packages.

Changes

Cohort / File(s) Summary
Me Endpoint Implementation
apps/meteor/app/api/server/v1/misc.ts, packages/rest-typings/src/v1/me.ts, .changeset/v1-me-endpoint-update.md
Introduced AJV-based validation for /api/v1/me endpoint with exported isMeProps validator and meEndpoints route definition including 401 error handling and schema validation. Updated type definitions with IMeResponse interface and MeParams type; simplified endpoint signature to use new param type.
Users Endpoint Updates
apps/meteor/app/api/server/v1/users.ts, packages/rest-typings/src/v1/users.ts
Added new GET users.getStatus route with authentication, validated response schema, and status retrieval logic. Removed old users.getStatus implementation. Updated GET users.getUsernameSuggestion route options to include userWithoutUsername: true. Removed corresponding endpoint definition from rest-typings.
Core Type System
packages/core-typings/src/Ajv.ts, packages/rest-typings/src/index.ts
Extended IUser support in AJV schemas type signature. Reordered MeEndpoints in Endpoints interface and added public re-export of me module.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type: chore


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/app/api/server/v1/misc.ts">

<violation number="1" location="apps/meteor/app/api/server/v1/misc.ts:53">
P3: `isMeProps` is defined but never applied to the `/api/v1/me` route (or anywhere else), leaving dead validator code and implying missing query validation. Either wire it via the route options (e.g., `query: isMeProps`) or remove the unused schema.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

},
additionalProperties: false,
};
export const isMeProps = ajv.compile<MeParams>(meSchema);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: isMeProps is defined but never applied to the /api/v1/me route (or anywhere else), leaving dead validator code and implying missing query validation. Either wire it via the route options (e.g., query: isMeProps) or remove the unused schema.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/app/api/server/v1/misc.ts, line 53:

<comment>`isMeProps` is defined but never applied to the `/api/v1/me` route (or anywhere else), leaving dead validator code and implying missing query validation. Either wire it via the route options (e.g., `query: isMeProps`) or remove the unused schema.</comment>

<file context>
@@ -32,154 +33,75 @@ import { API } from '../api';
+	},
+	additionalProperties: false,
+};
+export const isMeProps = ajv.compile<MeParams>(meSchema);
 
 /**
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant