From f888e80b013c02c275957b70f7a07972125f151a Mon Sep 17 00:00:00 2001 From: MathWhiz Date: Fri, 13 Jan 2017 15:06:46 -0600 Subject: [PATCH] apiDoc: meta (#8167) * apiDoc: meta * Update modelsPaths.js * Update error * fix test * Update GET-model_paths.test.js * Fixed test --- .../integration/models/GET-model_paths.test.js | 2 +- website/common/locales/en/front.json | 3 ++- .../server/controllers/api-v3/modelsPaths.js | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/test/api/v3/integration/models/GET-model_paths.test.js b/test/api/v3/integration/models/GET-model_paths.test.js index 0a9a94451a..9e4b4fb4fa 100644 --- a/test/api/v3/integration/models/GET-model_paths.test.js +++ b/test/api/v3/integration/models/GET-model_paths.test.js @@ -10,7 +10,7 @@ describe('GET /models/:model/paths', () => { user = await generateUser(); }); - it('returns an error when model is not accessible or doesn\'t exists', async () => { + it('returns an error when model is not accessible or doesn\'t exist', async () => { await expect(user.get('/models/1234/paths')).to.eventually.be.rejected.and.eql({ code: 400, error: 'BadRequest', diff --git a/website/common/locales/en/front.json b/website/common/locales/en/front.json index 9851e4df03..58a4452bd6 100644 --- a/website/common/locales/en/front.json +++ b/website/common/locales/en/front.json @@ -266,5 +266,6 @@ "invalidReqParams": "Invalid request parameters.", "memberIdRequired": "\"member\" must be a valid UUID.", "heroIdRequired": "\"heroId\" must be a valid UUID.", - "cannotFulfillReq":"Your request cannot be fulfilled. Email admin@habitica.com if this error persists." + "cannotFulfillReq":"Your request cannot be fulfilled. Email admin@habitica.com if this error persists.", + "modelNotFound":"This model does not exist." } diff --git a/website/server/controllers/api-v3/modelsPaths.js b/website/server/controllers/api-v3/modelsPaths.js index 32f4695a7a..93b8641b10 100644 --- a/website/server/controllers/api-v3/modelsPaths.js +++ b/website/server/controllers/api-v3/modelsPaths.js @@ -11,9 +11,24 @@ let allModels = ['user', 'tag', 'challenge', 'group'].concat(tasksModels); * @apiName GetUserModelPaths * @apiGroup Meta * - * @apiParam {String="user","group","challenge","tag","habit","daily","todo","reward"} model The name of the model + * @apiParam (Path) {String="user","group","challenge","tag","habit","daily","todo","reward"} model The name of the model + * + * @apiExample {curl} Tag + * curl https://habitica.com/api/v3/models/tag/paths * * @apiSuccess {Object} data A key-value object made of fieldPath: fieldType (like {'field.nested': Boolean}) + * + * @apiSuccessExample {json} Tag + * { + * "success":true, + * "data": { + * "id":"String", + * "name":"String", + * "challenge":"String" + * } + * } + * + * @apiError (400) {badRequest} modelNotFound The model specified was not found */ api.getModelPaths = { method: 'GET',