apiDoc: meta (#8167)

* apiDoc: meta

* Update modelsPaths.js

* Update error

* fix test

* Update GET-model_paths.test.js

* Fixed test
This commit is contained in:
MathWhiz
2017-01-13 15:06:46 -06:00
committed by Keith Holliday
parent fd7aedbff2
commit f888e80b01
3 changed files with 19 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ describe('GET /models/:model/paths', () => {
user = await generateUser(); 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({ await expect(user.get('/models/1234/paths')).to.eventually.be.rejected.and.eql({
code: 400, code: 400,
error: 'BadRequest', error: 'BadRequest',

View File

@@ -266,5 +266,6 @@
"invalidReqParams": "Invalid request parameters.", "invalidReqParams": "Invalid request parameters.",
"memberIdRequired": "\"member\" must be a valid UUID.", "memberIdRequired": "\"member\" must be a valid UUID.",
"heroIdRequired": "\"heroId\" 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."
} }

View File

@@ -11,9 +11,24 @@ let allModels = ['user', 'tag', 'challenge', 'group'].concat(tasksModels);
* @apiName GetUserModelPaths * @apiName GetUserModelPaths
* @apiGroup Meta * @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}) * @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 = { api.getModelPaths = {
method: 'GET', method: 'GET',