From 836ca2601714c2e6337cbbaaaf80e8b5275af821 Mon Sep 17 00:00:00 2001 From: NickOvt Date: Mon, 27 May 2024 09:47:37 +0300 Subject: [PATCH] fix(api-all): Fixes to some API endpoint request and/or response types and schemas ZMS-157 (#691) * Added submission api endpoint to api docs generation * fixes to different api paths --- lib/api/addresses.js | 9 ++++++--- lib/api/audit.js | 2 +- lib/api/certs.js | 1 + lib/api/domainaccess.js | 4 ++-- lib/api/filters.js | 6 ++---- lib/api/messages.js | 9 +++++---- lib/schemas/response/addresses-schemas.js | 5 ++++- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/api/addresses.js b/lib/api/addresses.js index d73da45f..6acbd7ac 100644 --- a/lib/api/addresses.js +++ b/lib/api/addresses.js @@ -742,6 +742,7 @@ module.exports = (db, server, userHandler, settingsHandler) => { 200: { description: 'Success', model: Joi.object({ + success: successRes, id: addressId, name: Joi.string().required().description('Identity name'), address: addressEmail, @@ -2163,7 +2164,8 @@ module.exports = (db, server, userHandler, settingsHandler) => { created: Joi.date().required().description('Datestring of the time the address was created'), tags: Joi.array().items(Joi.string()).required().description('List of tags associated with the Address'), metaData: Joi.object({}).description('Metadata object (if available)'), - internalData: Joi.object({}).description('Internal metadata object (if available), not included for user-role requests') + internalData: Joi.object({}).description('Internal metadata object (if available), not included for user-role requests'), + forwardedDisabled: booleanSchema.description('Specifies whether forwarding is disabled') }) } } @@ -2293,12 +2295,13 @@ module.exports = (db, server, userHandler, settingsHandler) => { id: addressId, address: addressEmail, name: Joi.string().required().description('Identity name'), - user: userId.description('ID of the user if the address belongs to a User'), targets: Joi.array().items(Joi.string()).description('List of forwarding targets if this is a Forwarded address'), limits: AddressLimits, autoreply: AutoreplyInfo, tags: Joi.array().items(Joi.string()).required().description('List of tags associated with the Address'), - created: Joi.date().required().description('Datestring of the time the address was created') + created: Joi.date().required().description('Datestring of the time the address was created'), + metaData: Joi.object({}).description('Metadata object (if available)'), + internalData: Joi.object({}).description('Internal metadata object (if available), not included for user-role requests') }) } } diff --git a/lib/api/audit.js b/lib/api/audit.js index f2466455..d001d5ee 100644 --- a/lib/api/audit.js +++ b/lib/api/audit.js @@ -177,7 +177,7 @@ module.exports = (db, server, auditHandler) => { requestBody: {}, queryParams: {}, pathParams: { audit: Joi.string().hex().lowercase().length(24).required().description('ID of the Audit') }, - response: { 200: { description: 'Success', model: Joi.object() } } + response: { 200: { description: 'Success', model: Joi.binary() } } }, responseType: 'application/octet-stream' }, diff --git a/lib/api/certs.js b/lib/api/certs.js index aceb3c11..22fd69f5 100644 --- a/lib/api/certs.js +++ b/lib/api/certs.js @@ -59,6 +59,7 @@ module.exports = (db, server) => { description: 'Success', model: Joi.object({ success: successRes, + query: Joi.string().description('Initial query'), total: totalRes, page: pageRes, previousCursor: previousCursorRes, diff --git a/lib/api/domainaccess.js b/lib/api/domainaccess.js index a2de7130..52aa9803 100644 --- a/lib/api/domainaccess.js +++ b/lib/api/domainaccess.js @@ -222,7 +222,7 @@ module.exports = (db, server) => { validationObjs: { requestBody: {}, queryParams: { - ess: sessSchema, + sess: sessSchema, ip: sessIPSchema }, pathParams: { @@ -325,7 +325,7 @@ module.exports = (db, server) => { validationObjs: { requestBody: {}, queryParams: { - ess: sessSchema, + sess: sessSchema, ip: sessIPSchema }, pathParams: { diff --git a/lib/api/filters.js b/lib/api/filters.js index 12aeb3ba..662361c8 100644 --- a/lib/api/filters.js +++ b/lib/api/filters.js @@ -88,7 +88,6 @@ module.exports = (db, server, userHandler, settingsHandler) => { // permissions check req.validate(permission); - let query = result.value.query; let forward = result.value.forward; let limit = result.value.limit; let page = result.value.page; @@ -174,7 +173,6 @@ module.exports = (db, server, userHandler, settingsHandler) => { let response = { success: true, - query, total, page, previousCursor: listing.hasPrevious ? listing.previous : false, @@ -641,8 +639,8 @@ module.exports = (db, server, userHandler, settingsHandler) => { requestBody: { name: Joi.string().trim().max(255).empty('').description('Name of the Filter'), - query: FilterQuery, - action: FilterAction, + query: FilterQuery.required(), + action: FilterAction.required(), disabled: booleanSchema.default(false).description('If true then this filter is ignored'), diff --git a/lib/api/messages.js b/lib/api/messages.js index aa9b35de..36b41993 100644 --- a/lib/api/messages.js +++ b/lib/api/messages.js @@ -1048,6 +1048,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti envelope: MsgEnvelope.required(), thread: Joi.string().required().description('ID of the Thread'), from: Address.required(), + replyTo: Address, to: Address, cc: Address, bcc: Address, @@ -1061,6 +1062,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti }) .description('If set then this message is from a mailing list') .$_setFlag('objectName', 'List'), + size: Joi.number().required().description('Message size'), expires: Joi.string().description('Datestring, if set then indicates the time after this message is automatically deleted'), seen: booleanSchema.required().description('Does this message have a \\Seen flag'), deleted: booleanSchema.required().description('Does this message have a \\Deleted flag'), @@ -1124,7 +1126,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti 'List of files added to this message as attachments. Applies to Drafts, normal messages do not have this property. Needed to prevent uploading the same attachment every time a draft is updated' ), outbound: Joi.array().items(Joi.object({})).description('Outbound queue entries'), - forwardTargets: Joi.object({}), + forwardTargets: Joi.object({}).description('Forward targets'), reference: Joi.object({}).description('Referenced message info'), answered: booleanSchema.required().description('\\Answered flag value'), forwarded: booleanSchema.required().description('$Forwarded flag value'), @@ -2072,7 +2074,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti mailbox: mailboxId }, requestBody: { - date: Joi.date(), + date: Joi.date().description('Date'), unseen: booleanSchema.default(false).description('Is the message unseen or not'), flagged: booleanSchema.default(false).description('Is the message flagged or not'), draft: booleanSchema.default(false).description('Is the message a draft or not'), @@ -3220,7 +3222,6 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti .try(Joi.string(), booleanSchema) .description('Either a cursor string or false if there are not any next results') .required(), - specialUse: Joi.string().description('Special use. If available').required(), results: Joi.array() .items( Joi.object({ @@ -3524,7 +3525,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti { name: 'archived_restore', path: '/users/:user/archived/messages/:message/restore', - summary: 'Restore archived messages ', + summary: 'Restore archived messages', description: 'Initiates a restore task to move archived messages of a date range back to the mailboxes the messages were deleted from. If target mailbox does not exist, then the messages are moved to INBOX.', tags: ['Archive'], diff --git a/lib/schemas/response/addresses-schemas.js b/lib/schemas/response/addresses-schemas.js index 52e7ed11..31491540 100644 --- a/lib/schemas/response/addresses-schemas.js +++ b/lib/schemas/response/addresses-schemas.js @@ -11,7 +11,10 @@ const GetAddressesResult = Joi.object({ user: Joi.string().required().description('User ID this address belongs to if this is a User address'), forwarded: booleanSchema.required().description('If true then it is a forwarded address'), forwardedDisabled: booleanSchema.required().description('If true then the forwarded address is disabled'), - target: Joi.array().items(Joi.string()).description('List of forwarding targets') + targets: Joi.array().items(Joi.string()).description('List of forwarding targets'), + tags: Joi.array().items().required().description('List of tags associated with the Address'), + metaData: Joi.object({}).description('Metadata object (if available)'), + internalData: Joi.object({}).description('Internal metadata object (if available), not included for user-role requests') }).$_setFlag('objectName', 'GetAddressesResult'); const GetUserAddressesResult = Joi.object({