chore: Add OpenAPI Support to emoji-custom.create API
Merged
AH
7mo ago+76+76+01234567890123456789-35-35-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 '[EmojiCustom]'
[EmojiCustom]
[/emoji-custom.create]
(node:18800) [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 create new custom emoji (91ms)
✔ should create new custom emoji without optional parameter "aliases" (97ms)
✔ should throw an error when the filename is wrong
[/emoji-custom.update]
successfully:
✔ should update the custom emoji without a file
✔ should update the custom emoji without optional parameter "aliases"
✔ should update the custom emoji with all parameters and with a file (93ms)
✔ should change the etag when the custom emoji image is updated (398ms)
should throw error when:
✔ the fields does not include "_id"
✔ the custom emoji does not exists
✔ the emoji file field is wrong
[/emoji-custom.list]
✔ should return emojis
✔ should return emojis when use "query" query parameter
✔ should return emojis when use "updateSince" query parameter
✔ should return emojis when use both, "updateSince" and "query" query parameter
✔ should return an error when the "updateSince" query parameter is a invalid date
[/emoji-custom.all]
✔ should return emojis
✔ should return emojis even requested with count and offset params
Accessing custom emojis
✔ should return forbidden if the there is no fileId on the url
✔ should return success if the file does not exists with some specific headers
✔ should return not modified if the file does not exists and if-modified-since is equal to the Thu, 01 Jan 2015 00:00:00 GMT
✔ should return success if the the requested exists
✔ should return not modified if the the requested file contains a valid-since equal to the upload date
✔ should return the emoji even when no etag is passed (for old emojis)
✔ should return success if the etag is invalid
[/emoji-custom.delete]
✔ should throw an error when trying delete custom emoji without the required param "emojid"
✔ should throw an error when trying delete custom emoji that does not exists
✔ should delete the custom emoji created before successfully
27 passing (1s)
Endpoints: (In progress)
Looking forward to your feedback! 🚀
Summary by CodeRabbit
- New Features
- OpenAPI-backed validation and structured responses for emoji creation, improving consistency.
- Bug Fixes
- Improved error handling for emoji creation with clearer, standardized error responses.
- Documentation
- Enhanced API docs for emoji creation with explicit request/response schemas.
- Chores
- Updated route and typing infrastructure to modern standards and shared schema usage.
Task: ARCH-1990
[COMM-144]