chore: Add OpenAPI Support to users.getAvatarSuggestion API
Merged
AH
7mo ago+125+125+012345678901234567890123456789-85-85-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.
- 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 '[Users]'
[Users]
✔ enabling E2E in server and generating keys to user... (144ms)
✔ should fail when trying to set keys for a user with keys already set
***
***
[/users.getAvatarSuggestion]
✔ should return 401 unauthorized when user is not logged in
✔ should get avatar suggestion of the logged user via userId (73ms)
***
***
205 passing (55s)
Endpoints:
-
Get Users' Avatar Suggestion
Looking forward to your feedback! 🚀
Summary by CodeRabbit
-
New Features
- Avatar suggestion endpoint exposed with OpenAPI documentation and clearer response/error definitions.
-
Improvements
- Token creation endpoint now uses stricter validation and returns a consistent response shape (success flag with data payload).
- API docs and response validation enhanced for more reliable client behavior.