Skip to content

Commit

Permalink
fix(api-all): Fixes to some API endpoint request and/or response type…
Browse files Browse the repository at this point in the history
…s and schemas ZMS-157 (#691)

* Added submission api endpoint to api docs generation

* fixes to different api paths
  • Loading branch information
NickOvt authored May 27, 2024
1 parent 2c511b5 commit 836ca26
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
9 changes: 6 additions & 3 deletions lib/api/addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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')
})
}
}
Expand Down Expand Up @@ -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')
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/api/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
Expand Down
1 change: 1 addition & 0 deletions lib/api/certs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/api/domainaccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module.exports = (db, server) => {
validationObjs: {
requestBody: {},
queryParams: {
ess: sessSchema,
sess: sessSchema,
ip: sessIPSchema
},
pathParams: {
Expand Down Expand Up @@ -325,7 +325,7 @@ module.exports = (db, server) => {
validationObjs: {
requestBody: {},
queryParams: {
ess: sessSchema,
sess: sessSchema,
ip: sessIPSchema
},
pathParams: {
Expand Down
6 changes: 2 additions & 4 deletions lib/api/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -174,7 +173,6 @@ module.exports = (db, server, userHandler, settingsHandler) => {

let response = {
success: true,
query,
total,
page,
previousCursor: listing.hasPrevious ? listing.previous : false,
Expand Down Expand Up @@ -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'),

Expand Down
9 changes: 5 additions & 4 deletions lib/api/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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'],
Expand Down
5 changes: 4 additions & 1 deletion lib/schemas/response/addresses-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 836ca26

Please sign in to comment.