chore: Add OpenAPI Support to commands.get API
Merged
AH
7mo ago+82+82+01234567890123456789-20-20-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 '[Commands]' [Commands] [/commands.get] ✔ should return an error when call the endpoint without "command" required parameter ✔ should return an error when call the endpoint with an invalid command ✔ should return success when parameters are correct [/commands.list] ✔ should return a list of commands ✔ should return a list of commands even requested with count and offset params (196ms) [/commands.run] ✔ should return an error when call the endpoint without "command" required parameter ✔ should return an error when call the endpoint with the param "params" and it is not a string ✔ should return an error when call the endpoint without "roomId" required parameter ✔ should return an error when call the endpoint with the param "tmid" and it is not a string ✔ should return an error when call the endpoint with the invalid "command" param ✔ should return an error when call the endpoint with an invalid thread id ✔ should return an error when call the endpoint with a valid thread id of wrong channel ✔ should return success when parameters are correct (140ms) Command archive unauthorized cases ✔ should return an error when the user is not logged in ✔ should return an error when the user has not enough permissions (42ms) authorized cases ✔ should return a success when the user has enough permissions (77ms) Command unarchive unauthorized cases ✔ should return an error when the user is not logged in ✔ should return an error when the user has not enough permissions authorized cases ✔ should return a success when the user has enough permissions Command "invite-all-from" ✔ should not add users from group which is not accessible by current user ✔ should not add users to a room that is not accessible by the current user ✔ should add users from group which is accessible by current user (127ms) 22 passing (7s)
Endpoints:
Looking forward to your feedback! 🚀
Summary by CodeRabbit
-
New Features
- Enhanced command retrieval endpoint with OpenAPI documentation support for improved API integration and discoverability
-
Refactor
- Modernized route definitions with strengthened validation framework and improved type-safe response handling for better reliability