chore: Add OpenAPI Support to Statistics API
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.
- 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 '[Statistics]'
[Statistics]
[/statistics]
✔ should return an error when the user does not have the necessary permission (248ms)
✔ should return an object with the statistics (224ms)
✔ should update the statistics when is provided the "refresh:true" query parameter (338ms)
[/statistics.list]
✔ should return an error when the user does not have the necessary permission (273ms)
✔ should return an array with the statistics (394ms)
✔ should return an array with the statistics even requested with count and offset params (202ms)
6 passing (2s)
Endpoints:
- statistics:
-
Statistics Telemetry
Looking forward to your feedback! 🚀
Description
This pull request introduces OpenAPI support to the statistics API in the ahmed-n-abdeltwab/Rocket.Chat repository. The changes are made in the apps/meteor/app/api/server/v1/stats.ts file. The update involves refactoring the statistics API routes to incorporate typed validation using ajv schema definitions. This enhancement aims to improve type safety and request validation while preserving the existing functionality of the API. The changes are proposed from the feat/OpenAPI branch to be merged into the develop branch.