Skip to content

Commit

Permalink
Fix INSERT/PATCH data blob APIs in Swagger UI
Browse files Browse the repository at this point in the history
  • Loading branch information
nicou committed Jun 10, 2024
1 parent 6d82d95 commit 8970fd2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/routes/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ function deleteData(dataType, dataId) {
});
}

/**
* @typedef DataBlob
* @property {string} id - ID
* @property {string} type - Data type
*/

/**
* Get all data blobs of all types.
*
* @route GET /data
* @group Data - Generic data store operations
* @returns {object} 200 - Array of all data blobs
* @returns {Array.<DataBlob>} 200 - Array of all data blobs
*/
router.get('/', (req, res) => {
const state = store.getState().data;
Expand All @@ -58,7 +64,7 @@ router.get('/', (req, res) => {
* @route GET /data/{type}
* @group Data - Generic data store operations
* @param {string} type.path.required - Data type
* @returns {object} 200 - Array of data blobs
* @returns {Array.<DataBlob>} 200 - Array of data blobs
*/
router.get('/:type', (req, res) => {
const { type } = req.params;
Expand All @@ -67,22 +73,20 @@ router.get('/:type', (req, res) => {
res.json(Object.values(datas));
});


/**
* Get a specific data blob by type and id.
*
* @route GET /data/{type}/{id}
* @group Data - Generic data store operations
* @param {string} id.path.required - Data id
* @param {string} type.path.required - Data type
* @returns {object} 200 - Data value
* @returns {DataBlob.model} 200 - Data value
*/
router.get('/:type/:id', (req, res) => {
const { type, id } = req.params;
return res.json(getData(type, id));
});


/**
* Set a specific data blob by type and id. Overwrites entire data.
*
Expand All @@ -93,7 +97,7 @@ router.get('/:type/:id', (req, res) => {
* @group Data - Generic data store operations
* @param {string} id.path.required - Data id
* @param {string} type.path.required - Data type
* @param {object} body.required - New data value
* @param {DataBlob.model} data.body.required - New data value
* @param {boolean} force.query - Force value to be set regardless of version
* @returns {object} 200 - Updated data value
* @returns {Error} 409 - Error if submitted version is different that current version
Expand All @@ -106,7 +110,6 @@ router.post('/:type/:id', (req, res) => {
res.json(getData(type, id));
});


/**
* Update a specific data blob by type and id. Keeps those fields which are not present in payload.
*
Expand All @@ -117,7 +120,7 @@ router.post('/:type/:id', (req, res) => {
* @group Data - Generic data store operations
* @param {string} id.path.required - Data id
* @param {string} type.path.required - Data type
* @param {object} body.required - Fields to update
* @param {DataBlob.model} data.body.required - Fields to update
* @param {boolean} force.query - Force value to be set regardless of version
* @returns {object} 200 - Updated data value
* @returns {Error} 409 - Error if submitted version is different that current version
Expand Down

0 comments on commit 8970fd2

Please sign in to comment.