From 849c28a8d03d859af13f643f1de9e10e7080a38d Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 16 Nov 2016 12:40:38 -0700 Subject: [PATCH] [docs] add body parameter to all methods that accept it --- scripts/generate/templates/api_methods.tmpl | 22 ++++++++++++++++++--- scripts/generate/templates/index.js | 4 ++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/scripts/generate/templates/api_methods.tmpl b/scripts/generate/templates/api_methods.tmpl index c116bbcee..d098e592d 100644 --- a/scripts/generate/templates/api_methods.tmpl +++ b/scripts/generate/templates/api_methods.tmpl @@ -31,8 +31,8 @@ The default method is `<%= action.spec.method || 'GET' %>` and the usual < +} + +_.each(action.allParams, printParam) + +if (action.spec.method && action.spec.method !== 'GET') { + var bodyTitle = `${action.spec.needBody ? 'The' : 'An optional'} request body` + var bodyTypeDesc = action.spec.bulkBody + ? 'as either an array of objects or new-line delimited JSON objects' + : 'as either JSON or a JSON serializable object' + + printParam({ + type: action.spec.bulkBody ? 'bulkbody' : 'body', + description: `${bodyTitle}, ${bodyTypeDesc}. See ${action.docUrl}[the elasticsearch docs] for details about what can be specified here.` + }, 'body') +} + +%> link:#[back to top]<% diff --git a/scripts/generate/templates/index.js b/scripts/generate/templates/index.js index 5a30086c3..c450076d8 100644 --- a/scripts/generate/templates/index.js +++ b/scripts/generate/templates/index.js @@ -77,6 +77,10 @@ var templateGlobals = { return 'String'; case 'list': return 'String, String[], Boolean'; + case 'bulkbody': + return 'Object[], JSONLines'; + case 'body': + return 'Object, JSON'; default: return _.ucfirst(type); }