feat: Add OpenAPI Support to subscriptions.getOne API
Draft
AH
6mo ago+71+71+01234567890123456789-38-38-01234567890123456789
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 '[Subscriptions]' [Subscriptions] ✔ /subscriptions.get ✔ /subscriptions.get?updatedSince /subscriptions.getOne ✔ should fail if no roomId provided ✔ should fail if not logged in ✔ should return the subscription with success ✔ should keep subscription as read after sending a message (162ms) [/subscriptions.read] ✔ should mark public channels as read ✔ should mark groups as read ✔ should mark DMs as read ✔ should fail on two params with different ids ✔ should fail on mark inexistent public channel as read ✔ should fail on mark inexistent group as read ✔ should fail on mark inexistent DM as read ✔ should fail on invalid params ✔ should fail on empty params should handle threads correctly ✔ should mark threads as read (76ms) ✔ should not mark threads as read (99ms) [/subscriptions.unread] ✔ should fail when there are no messages on an channel ✔ sending message (83ms) ✔ should return success: true when make as unread successfully (44ms) ✔ should fail on invalid params ✔ should fail on empty params 22 passing (8s)
Endpoints:
Looking forward to your feedback! 🚀
Summary by CodeRabbit
-
New Features
- Added a dedicated subscriptions.getOne endpoint returning a room-specific subscription or null with consistent success/error responses.
-
Documentation
- OpenAPI docs updated with detailed request/response schemas for the new endpoint.
-
Refactor
- Endpoint migrated to a modern route definition with local JSON-schema validation.
-
Tests
- End-to-end tests updated to expect the new error format (includes errorType) and stricter roomId validation.