diff --git a/app/routes/cache.routes.js b/app/routes/cache.routes.js index b75331c77cccaf417da2676f695ebe86156548aa..4bfea05ddc5b65a1862a2cf1bd8dbe31449b2737 100644 --- a/app/routes/cache.routes.js +++ b/app/routes/cache.routes.js @@ -4,12 +4,65 @@ module.exports = (app) => { const cache = require('../controllers/cache.controller.js'); const auth = require('../authentication/icat.js'); + + /** + * @swagger + * /cache: + * get: + * description: Gets the cache of a user given a specific sessionId + * responses: + * '200': + * content: + * application/json: + * type: array + * schema: + * $ref: '#/components/schemas/cacheUserStorage' + * tags: + * - Cache + */ app.get('/cache', cache.getSessionById); + /** + * @swagger + * /cache/stats: + * get: + * description: Gets the statistics for the use of cache + * responses: + * '200': + * content: + * application/json: + * type: array + * schema: + * $ref: '#/components/schemas/cacheStats' + * tags: + * - Cache + */ app.get('/cache/stats', cache.getStats); + /** + * @swagger + * /cache/keys: + * get: + * description: Gets the keys stored in the cache + * responses: + * '200': + * description: 'Ok' + * tags: + * - Cache + */ app.get('/cache/keys', auth.allowAdministrators, cache.getCacheKeys); + /** + * @swagger + * /cache/keys/:key: + * get: + * description: Gets the content of a key + * responses: + * '200': + * description: 'Ok' + * tags: + * - Cache + */ app.get('/cache/keys/:key', auth.allowAdministrators, cache.getCacheKey); diff --git a/app/routes/definitions.js b/app/routes/definitions.js index 6f68f651defc34dbaf9e9c53be502479a2dbb852..1941deaf3cb7ed877129d8805293bd3245f49ec5 100644 --- a/app/routes/definitions.js +++ b/app/routes/definitions.js @@ -286,6 +286,45 @@ * type: "string" * dateType: * type: "string" + * cacheStats: + * required: + * - "hits" + * - "misses" + * - "keys" + * - "ksize" + * - "vsize" + * properties: + * hits: + * type: "number" + * misses: + * type: "number" + * keys: + * type: "number" + * ksize: + * type: "number" + * vsize: + * type: "number" + * cacheUserStorage: + * required: + * - "username" + * - "myInvestigations" + * - "investigations" + * - "investigationsId" + * properties: + * username: + * type: "string" + * myInvestigations: + * type: "array" + * items: + * $ref: '#/components/schemas/investigation' + * investigations: + * type: "array" + * items: + * $ref: '#/components/schemas/investigation' + * investigationsId: + * type: "array" + * items: + * $ref: '#/components/schemas/investigation' * event: * description: an event in the logbook * type: object diff --git a/app/routes/file.routes.js b/app/routes/file.routes.js index ccb86b23d9c8f557833d7f9705ed63109bb84690..9a2cde24cef58cb6ef0e8fbb4613ecc5355d36cb 100644 --- a/app/routes/file.routes.js +++ b/app/routes/file.routes.js @@ -5,7 +5,7 @@ module.exports = (app) => { /** * @swagger * /investigations/:investigationId/events/file: - * get: + * post: * description: Uploads a file to ICAT+ * parameters: * - in: path @@ -30,6 +30,11 @@ module.exports = (app) => { * responses: * '200': * description : 'Ok' + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/event' + * * '500': * $ref: '#/components/responses/error500' * tags: diff --git a/test/resources/investigations.resource.js b/test/resources/investigations.resource.js index bdcb9b95b140e504d455c82e2613778c3737f6a0..d38af3475a7a8f6c9cb6084703ec46db759329a7 100644 --- a/test/resources/investigations.resource.js +++ b/test/resources/investigations.resource.js @@ -1,27 +1,27 @@ module.exports = { normalize: [{ "input": "MX0000", - "normalized": "MX-0000" + "expected": "MX-0000" }, { "input": "ihls3203", - "normalized": "IH-LS-3203" + "expected": "IH-LS-3203" }, { "input": "ih-ls3203", - "normalized": "IH-LS-3203" + "expected": "IH-LS-3203" }, { "input": "ih-ls-3203", - "normalized": "IH-LS-3203" + "expected": "IH-LS-3203" }, { "input": "ev280", - "normalized": "EV-280" + "expected": "EV-280" }, { "input": "ip0001", - "normalized": "IP-0001" + "expected": "IP-0001" } ], diff --git a/test/routes/test.investigations.routes.js b/test/routes/test.investigations.routes.js index 76c5f471651e9e05ac62a7be39895afbd1cf836d..1bb33f9782ac8e5ebad8d6636dadace4f4177217 100644 --- a/test/routes/test.investigations.routes.js +++ b/test/routes/test.investigations.routes.js @@ -45,10 +45,10 @@ describe('Investigations', () => { .get('/investigations/' + element.input + '/normalize') .set('Content-Type', 'application/json') .send() - .end((err, response) => { - expect(response.status).to.equal(200); - expect(response.text).to.equal(element.normalized); - next(); + .end((err, response) => { + expect(response.status).to.equal(200); + expect(response.text).to.equal(element.expected); + next(); }); }) })