feat: Add OpenAPI Support to Webdav API #35884
feat: Add OpenAPI Support to Webdav API #35884kodiakhq[bot] merged 8 commits intoRocketChat:developfrom
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 8e5fc1d The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
✅ Test Results$ yarn testapi -f 'Webdav'
[Webdav]
/webdav.getMyAccounts
✔ should return my webdav accounts
/webdav.removeWebdavAccount
✔ should return an error when send an invalid request (62ms)
✔ should return an error when using an invalid account id
3 passing (945ms) |
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Status
✅ Test Results$ yarn testapi -f 'Webdav'
[Webdav]
/webdav.getMyAccounts
✔ should return my webdav accounts
/webdav.removeWebdavAccount
✔ should return an error when send an invalid request
✔ should return an error when using an invalid account id
3 passing (576ms)GitHub Copilot ReviewYour code is well-structured and adheres to good practices for API design and TypeScript usage. However, here are some suggestions for improvement: 1. Error Handling
if (!removed) {
return API.v1.failure({
error: 'Account not found or could not be removed.',
});
}2. Code Duplication
body: ajv.compile(POSTRemoveWebdavAccountSchema),3. Response Consistency
const accountsForResponse = userAccounts.map(({ userId, serverURL, username, name }) => ({
userId,
serverURL,
username,
name,
}));4. Logging
console.log(`User ${this.userId} removed WebDAV account ${accountId}`);5. Security
6. Performance
7. Documentation
/**
* GET /webdav.getMyAccounts
* Retrieves all WebDAV accounts for the authenticated user.
*/8. Type Safety
const removed: { acknowledged: boolean; deletedCount: number } | null = await WebdavAccounts.removeByUserAndId(accountId, this.userId);9. Common Schema Extraction
10. Testing
Example Refactor for
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
1 similar comment
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Summary
✅ Test Results$ yarn testapi -f 'Webdav'
[Webdav]
/webdav.getMyAccounts
✔ should return my webdav accounts (42ms)
/webdav.removeWebdavAccount
✔ should return an error when send an invalid request
✔ should return an error when using an invalid account id
3 passing (625ms) |
|
Please run the CI. I've fixed the previous errors in the Code Check / Code Lint. |
a6b93a6 to
c1add5c
Compare
Description:
This PR integrates OpenAPI support into the
Rocket.Chat API, migrate ofRocket.Chat APIendpoints to the new OpenAPI pattern. The update includes improved API documentation, enhanced type safety, and response validation using AJV.Key Changes:
Issue Reference:
Relates to #34983, part of the ongoing OpenAPI integration effort.
Testing:
Endpoints:
Get WebDAV Accounts
Remove WebDAV Account
Looking forward to your feedback! 🚀
This pull request introduces OpenAPI support to the WebDAV API in the Rocket.Chat repository. The changes are made in the
apps/meteor/app/api/server/v1/webdav.tsfile. The update refactors two WebDAV API endpoints,getMyAccountsandremoveWebdavAccount, to utilize a modern chained route definition syntax (API.v1.get,API.v1.post). Additionally, it replaces a local AJV instance with a shared one from@rocket.chat/rest-typings, enhancing the API's robustness. Comprehensive AJV-based validation schemas for request bodies and responses are added, improving the overall validation process. The source branch for this feature isfeat/openapi-webdav, and it targets thedevelopbranch.https://rocketchat.atlassian.net/browse/ARCH-1695