Skip to content

Conversation

@ahmed-n-abdeltwab
Copy link
Contributor

@ahmed-n-abdeltwab ahmed-n-abdeltwab commented Aug 11, 2025

Description:
This PR integrates OpenAPI support into the Rocket.Chat API, migrate of Rocket.Chat API endpoints to the new OpenAPI pattern. The update includes improved API documentation, enhanced type safety, and response validation using AJV.

Key Changes:

  • Implemented the new pattern and added AJV-based JSON schema validation for API.
  • Uses the ExtractRoutesFromAPI utility from the TypeScript definitions to dynamically derive the routes from the endpoint specifications.
  • Enabled Swagger UI integration for this API.
  • Route Methods Chaining for the endpoints.
  • This does not introduce any breaking changes to the endpoint logic.

Issue Reference:
Relates to #34983, part of the ongoing OpenAPI integration effort.

Testing:

  • Verified that the API response schemas are correctly documented in Swagger UI.

  • All tests passed without any breaking changes

    $ yarn testapi -f '[Direct Messages]'      
    
    
    [Direct Messages]
      ✔ /im.history (39ms)
      ✔ /im.list
      ✔ /im.open (41ms)
      ✔ /im.close (46ms)
      /im.setTopic
        ✔ should set the topic of the DM with a string (64ms)
        ✔ should set the topic of DM with an empty string(remove the topic) (57ms)
      Testing DM info
        ✔ sending a message... (95ms)
        ✔ REACTing with last message (43ms)
        ✔ STARring last message (55ms)
        ✔ PINning last message (269ms)
        ✔ should return all DM messages where the last message of array should have the "star" array with USERS star ONLY (85ms)
      /im.list.everyone
        ✔ should succesfully return a list of direct messages (62ms)
        ✔ should fail if user does NOT have the view-room-administration permission (255ms)
      Setting: 'Use Real Name': true
        ✔ /im.list (56ms)
        ✔ /im.list.everyone (50ms)
      /im.counters
        ✔ should require auth
        ✔ should require a roomId (54ms)
        ✔ should work with all params right (62ms)
        with valid room id
          ✔ should properly return counters before opening the dm (49ms)
        with deactived users
          ✔ should not include deactivated users in members count (115ms)
      [/im.files]
        ✔ should fail if invalid channel
        ✔ should fail for room type v (1058ms)
        ✔ should succeed when searching by roomId
        ✔ should succeed when searching by roomId even requested with count and offset params (43ms)
        - should succeed when searching by roomName
        - should succeed when searching by roomName even requested with count and offset params
         (node:22035) [DEP0044] DeprecationWarning: The `util.isArray` API is deprecated. Please use `Array.isArray()` instead.
         (Use `node --trace-deprecation ...` to show where the warning was created)
        ✔ should not return thumbnails (394ms)
        ✔ should not return hidden files (311ms)
        ✔ should properly filter files by name or typeGroup (445ms)
      /im.messages
        ✔ should return all DM messages that were sent to yourself using your username (104ms)
        ✔ should sort by ts by default
        ✔ should allow custom sorting (68ms)
        ✔ should return an error when trying to access a DM that does not belong to the current user
        ✔ should return messages that mention a single user
        ✔ should return messages that mention multiple users
        ✔ should return messages that are starred by a specific user
        ✔ should return messages that are pinned
      /im.messages.others
        ✔ should fail when the endpoint is disabled and the user has permissions (254ms)
        ✔ should fail when the endpoint is disabled and the user doesnt have permission (395ms)
        ✔ should fail when the endpoint is enabled but the user doesnt have permission (383ms)
        ✔ should succeed when the endpoint is enabled and user has permission (407ms)
      fname property
        ✔ should have fname property
        ✔ should update user's name (83ms)
        ✔ should have fname property updated
      /im.members
        ✔ should return and array with two members (44ms)
        ✔ should return and array with one member
        ✔ should return and array with one member queried by status
      /im.create
        ✔ creates a DM between two other parties (including self) (40ms)
        ✔ creates a DM between two other parties (excluding self) (51ms)
        ✔ should create a self-DM
        should create dm with correct notification preferences
          ✔ should save user preferences
          ✔ should create a DM (44ms)
          ✔ should return the right user notification preferences in the dm
        Rooms fullName
          ✔ should be own user's name for self DM
          ✔ should be other user's name concatenated for multiple users's DM for every user (44ms)
          ✔ should be other user's name for DM for both users
      /im.delete
        ✔ /im.create
        ✔ /im.delete (71ms)
        ✔ /im.open
        when authenticated as a non-admin user
          ✔ /im.create
          ✔ /im.delete
    
    
    59 passing (20s)
    2 pending

Endpoints:

Looking forward to your feedback! 🚀

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 11, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2025

🦋 Changeset detected

Latest commit: 1349b72

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

This PR includes changesets to release 39 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/rest-typings Patch
@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 Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/stream-hub-service 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/network-broker 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/omni-core-ee Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/core-typings Patch
@rocket.chat/apps Patch
@rocket.chat/freeswitch 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

@ahmed-n-abdeltwab
Copy link
Contributor Author

@cardoso ready for review

@ahmed-n-abdeltwab ahmed-n-abdeltwab marked this pull request as ready for review August 11, 2025 17:44
@ahmed-n-abdeltwab ahmed-n-abdeltwab requested review from a team as code owners August 11, 2025 17:44
Copy link
Member

@cardoso cardoso left a comment

Choose a reason for hiding this comment

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

👍 @ggazzo

@cardoso cardoso added this to the 7.10.0 milestone Aug 11, 2025
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Aug 11, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Aug 11, 2025
@ggazzo ggazzo merged commit 1ca92c3 into RocketChat:develop Aug 11, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gsoc-project stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants