RESTAPI: Add some JSDoc

So we can have a decent REST API documentation generated.
This commit is contained in:
Benjamin Tissoires 2018-10-26 07:27:24 +02:00
parent 49d3eb5a3f
commit ff467402c0
11 changed files with 994 additions and 11 deletions

View file

@ -1,21 +1,39 @@
ChecklistItems = new Mongo.Collection('checklistItems');
/**
* An item in a checklist
*/
ChecklistItems.attachSchema(new SimpleSchema({
title: {
/**
* the text of the item
*/
type: String,
},
sort: {
/**
* the sorting field of the item
*/
type: Number,
decimal: true,
},
isFinished: {
/**
* Is the item checked?
*/
type: Boolean,
defaultValue: false,
},
checklistId: {
/**
* the checklist ID the item is attached to
*/
type: String,
},
cardId: {
/**
* the card ID the item is attached to
*/
type: String,
},
}));
@ -193,6 +211,17 @@ if (Meteor.isServer) {
}
if (Meteor.isServer) {
/**
* @operation get_checklist_item
* @tag Checklists
* @summary Get a checklist item
*
* @param {string} boardId the board ID
* @param {string} cardId the card ID
* @param {string} checklistId the checklist ID
* @param {string} itemId the ID of the item
* @return_type ChecklistItems
*/
JsonRoutes.add('GET', '/api/boards/:boardId/cards/:cardId/checklists/:checklistId/items/:itemId', function (req, res) {
Authentication.checkUserId( req.userId);
const paramItemId = req.params.itemId;
@ -209,6 +238,19 @@ if (Meteor.isServer) {
}
});
/**
* @operation edit_checklist_item
* @tag Checklists
* @summary Edit a checklist item
*
* @param {string} boardId the board ID
* @param {string} cardId the card ID
* @param {string} checklistId the checklist ID
* @param {string} itemId the ID of the item
* @param {string} [isFinished] is the item checked?
* @param {string} [title] the new text of the item
* @return_type {_id: string}
*/
JsonRoutes.add('PUT', '/api/boards/:boardId/cards/:cardId/checklists/:checklistId/items/:itemId', function (req, res) {
Authentication.checkUserId( req.userId);
@ -229,6 +271,19 @@ if (Meteor.isServer) {
});
});
/**
* @operation delete_checklist_item
* @tag Checklists
* @summary Delete a checklist item
*
* @description Note: this operation can't be reverted.
*
* @param {string} boardId the board ID
* @param {string} cardId the card ID
* @param {string} checklistId the checklist ID
* @param {string} itemId the ID of the item to be removed
* @return_type {_id: string}
*/
JsonRoutes.add('DELETE', '/api/boards/:boardId/cards/:cardId/checklists/:checklistId/items/:itemId', function (req, res) {
Authentication.checkUserId( req.userId);
const paramItemId = req.params.itemId;