From bd9dcbf2597a9a7a6decb525532e5bf48a6c9d5c Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Mon, 22 Apr 2024 13:45:25 +0300 Subject: [PATCH] Added delete a File api endpoint to api docs generation --- lib/api/storage.js | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/api/storage.js b/lib/api/storage.js index 16ace7e5..a704fde6 100644 --- a/lib/api/storage.js +++ b/lib/api/storage.js @@ -309,15 +309,39 @@ module.exports = (db, server, storageHandler) => { ); server.del( - '/users/:user/storage/:file', + { + path: '/users/:user/storage/:file', + tags: ['Storage'], + summary: 'Delete a File', + validationObjs: { + requestBody: {}, + queryParams: { + sess: sessSchema, + ip: sessIPSchema + }, + pathParams: { + user: userId, + file: Joi.string().hex().lowercase().length(24).required().description('ID of the File') + }, + 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(), - file: Joi.string().hex().lowercase().length(24).required(), - sess: sessSchema, - ip: sessIPSchema + const { requestBody, queryParams, pathParams } = req.route.spec.validationObjs; + + const schema = Joi.object({ + ...requestBody, + ...queryParams, + ...pathParams }); const result = schema.validate(req.params, {