Skip to content

Commit 910b9c7

Browse files
committed
added Delete a Mailbox endpoint to API generation. Add example to Request Mailbox information API endpoint
1 parent 74ebc82 commit 910b9c7

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

lib/api/mailboxes.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ module.exports = (db, server, mailboxHandler) => {
389389
path: Joi.string()
390390
.required()
391391
.description('Full path of the mailbox, folders are separated by slashes, ends with the mailbox name (unicode string)'),
392-
specialUse: Joi.string().required().description('Either special use identifier or null. One of Drafts, Junk, Sent or Trash'),
392+
specialUse: Joi.string()
393+
.required()
394+
.example('\\Draft')
395+
.description('Either special use identifier or null. One of Drafts, Junk, Sent or Trash'),
393396
modifyIndex: Joi.number().required().description('Modification sequence number. Incremented on every change in the mailbox.'),
394397
subscribed: booleanSchema.required().description('Mailbox subscription status. IMAP clients may unsubscribe from a folder.'),
395398
hidden: booleanSchema.required().description('Is the folder hidden or not'),
@@ -620,15 +623,33 @@ module.exports = (db, server, mailboxHandler) => {
620623
);
621624

622625
server.del(
623-
'/users/:user/mailboxes/:mailbox',
626+
{
627+
path: '/users/:user/mailboxes/:mailbox',
628+
summary: 'Delete a Mailbox',
629+
tags: ['Mailboxes'],
630+
validationObjs: {
631+
requestBody: { user: userId, mailbox: mailboxId },
632+
queryParams: { sess: sessSchema, ip: sessIPSchema },
633+
pathParams: {},
634+
response: {
635+
200: {
636+
description: 'Success',
637+
model: Joi.object({
638+
success: successRes
639+
})
640+
}
641+
}
642+
}
643+
},
624644
tools.responseWrapper(async (req, res) => {
625645
res.charSet('utf-8');
626646

627-
const schema = Joi.object().keys({
628-
user: Joi.string().hex().lowercase().length(24).required(),
629-
mailbox: Joi.string().hex().lowercase().length(24).required(),
630-
sess: sessSchema,
631-
ip: sessIPSchema
647+
const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs;
648+
649+
const schema = Joi.object({
650+
...pathParams,
651+
...requestBody,
652+
...queryParams
632653
});
633654

634655
const result = schema.validate(req.params, {

0 commit comments

Comments
 (0)