From 1439446b36f5c7b52c47732d85b7fb529dca7cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 11 Oct 2016 16:31:57 +0200 Subject: [PATCH] Fix description of updateAll response Correctly describe the first non-error callback arg as an `info` object containing a `count` property. --- lib/persisted-model.js | 11 ++++++++--- test/remoting.integration.js | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/persisted-model.js b/lib/persisted-model.js index d3a5c597..195b0f2e 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -808,9 +808,14 @@ module.exports = function(registry) { description: 'An object of model property name/value pairs' }, ], returns: { - arg: 'count', - description: 'The number of instances updated', - type: 'object', + arg: 'info', + description: 'Information related to the outcome of the operation', + type: { + count: { + type: 'number', + description: 'The number of instances updated', + }, + }, root: true, }, http: { verb: 'post', path: '/update' }, diff --git a/test/remoting.integration.js b/test/remoting.integration.js index f21c4203..75a5f5f4 100644 --- a/test/remoting.integration.js +++ b/test/remoting.integration.js @@ -262,6 +262,12 @@ function formatReturns(m) { return ''; } var type = returns[0].type; + + // handle anonymous type definitions, e.g + // { arg: 'info', type: { count: 'number' } } + if (typeof type === 'object' && !Array.isArray(type)) + type = 'object'; + return type ? ':' + type : ''; }