From 910b9c76b49a9b7da5ee2ec7341e6787fba586b1 Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Mon, 8 Jan 2024 12:20:04 +0200 Subject: [PATCH] added Delete a Mailbox endpoint to API generation. Add example to Request Mailbox information API endpoint --- lib/api/mailboxes.js | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/api/mailboxes.js b/lib/api/mailboxes.js index b802bd57..7e6df492 100644 --- a/lib/api/mailboxes.js +++ b/lib/api/mailboxes.js @@ -389,7 +389,10 @@ module.exports = (db, server, mailboxHandler) => { path: Joi.string() .required() .description('Full path of the mailbox, folders are separated by slashes, ends with the mailbox name (unicode string)'), - specialUse: Joi.string().required().description('Either special use identifier or null. One of Drafts, Junk, Sent or Trash'), + specialUse: Joi.string() + .required() + .example('\\Draft') + .description('Either special use identifier or null. One of Drafts, Junk, Sent or Trash'), modifyIndex: Joi.number().required().description('Modification sequence number. Incremented on every change in the mailbox.'), subscribed: booleanSchema.required().description('Mailbox subscription status. IMAP clients may unsubscribe from a folder.'), hidden: booleanSchema.required().description('Is the folder hidden or not'), @@ -620,15 +623,33 @@ module.exports = (db, server, mailboxHandler) => { ); server.del( - '/users/:user/mailboxes/:mailbox', + { + path: '/users/:user/mailboxes/:mailbox', + summary: 'Delete a Mailbox', + tags: ['Mailboxes'], + validationObjs: { + requestBody: { user: userId, mailbox: mailboxId }, + queryParams: { sess: sessSchema, ip: sessIPSchema }, + pathParams: {}, + response: { + 200: { + description: 'Success', + model: Joi.object({ + success: successRes + }) + } + } + } + }, tools.responseWrapper(async (req, res) => { res.charSet('utf-8'); - const schema = Joi.object().keys({ - user: Joi.string().hex().lowercase().length(24).required(), - mailbox: Joi.string().hex().lowercase().length(24).required(), - sess: sessSchema, - ip: sessIPSchema + const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs; + + const schema = Joi.object({ + ...pathParams, + ...requestBody, + ...queryParams }); const result = schema.validate(req.params, {