diff --git a/lib/services.template b/lib/services.template index 93bc21c..eb3a70d 100644 --- a/lib/services.template +++ b/lib/services.template @@ -68,44 +68,75 @@ action.description = '\n' + } -%> * <%-: action.description | replace:/\n/g, '\n * ' %> * +<% +var params = action.accepts; +var postData; +if (action.getHttpMethod() == 'POST' || action.getHttpMethod() == 'PUT') { + params = params.filter(function(arg) { + return arg.http && (arg.http.source == 'query' || arg.http.source == 'path'); + }); + postData = action.accepts.filter(function(arg) { + return params.indexOf(arg) == -1; + }); +} +-%> * @param {Object=} parameters Request parameters. -<% if (action.getHttpMethod() == 'POST' || action.getHttpMethod() == 'PUT') { -%> +<% if (params.length == 0) { -%> + * + * This method does not accept any parameters. + * Supply an empty object or omit this argument altogether. +<% } else { params.forEach(function(arg) { -%> + * + * - `<%- arg.arg %>` – `{<%- getJsDocType(arg) %>}` - <%- +(arg.description || '').replace(/\n/g, '\n * ') %> +<% }); } -%> +<% if (postData) { -%> * * @param {Object} postData Request data. -<% } -%> -<% if (!action.accepts || action.accepts.length == 0) { -%> - * This method does not accept any parameters. Supply an empty object. -<% } else if (action.acceptsSingleBodyArgument(action.accepts)) { -%> - * This method expects a subset of model properties as request parameters. -<% } else { -%> +<% if (postData.length == 0) { -%> * - * Object properties: -<% action.accepts.forEach(function(arg) { -%> + * This method does not accept any data. Supply an empty object. +<% } else if (postData.length == 1 && postData[0].http && + postData[0].http.source == 'body') { -%> * - * - `<%- arg.arg %>` – `{<%- getJsDocType(arg) %>}` - <%- + * This method expects a subset of model properties as request parameters. +<% } else { +postData.forEach(function(arg) { -%> + * + * - `<%- arg.arg %>` – `{<%- getJsDocType(arg) %>}` - <%- (arg.description || '').replace(/\n/g, '\n * ') %> <% }); - } --%> + } +} -%> * -<% var returnType = action.isReturningArray() ? 'Array.': 'Object'; %> +<% var returnType = action.isReturningArray() ? 'Array.': 'Object'; -%> * @param {Function(<%- returnType %>, Object)=} successCb - * Success callback with two arguments: `value`, `responseHeaders`. + * Success callback with two arguments: `value`, `responseHeaders`. * * @param {Function(Object)=} errorCb Error callback with one argument: - * `httpResponse`. + * `httpResponse`. * * @return {<%- returnType %>} An empty reference that will be * populated with the actual data once the response is returned * from the server. + * <% if (!action.returns || action.returns.length == 0) { -%> * This method returns no data. -<% } else if (!action.returns[0].root) { -%> - * +<% } else if (action.returns[0].root) { -%> +<% if (action.returns[0].description) { -%> + * <%- action.returns[0].description +.replace(/\n/g, '\n * ').trimRight() %> +<% } else { -%> + * + * (The remote method definition does not provide any description. + * This usually means the response is a `<%- modelName %>` object.) + * +<% } -%> +<% } else { -%> * Data properties: <% action.returns.forEach(function(arg) { -%> * - * - `<%- arg.arg %>` – `{<%- getJsDocType(arg) %>}` - <%- + * - `<%- arg.arg %>` – `{<%- getJsDocType(arg) %>}` - <%- (arg.description || '').replace(/\n/g, '\n * ') %> <% }); }