[pve-devel] [PATCH docs] api-viewer: show full return info if available
Dominik Csapak
d.csapak at proxmox.com
Thu Mar 22 10:03:12 CET 2018
Great, this will definitely be helpful to new developers of api clients :)
Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>
Tested-by: Dominik Csapak <d.csapak at proxmox.com>
On 03/21/2018 03:53 PM, Thomas Lamprecht wrote:
> if we have extended information available about what a API call
> returns the show it.
>
> Just stringify the items and/or properties object and put it in <pre>
> tags.
>
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
> api-viewer/PVEAPI.js | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/api-viewer/PVEAPI.js b/api-viewer/PVEAPI.js
> index 409214d..a167b4c 100644
> --- a/api-viewer/PVEAPI.js
> +++ b/api-viewer/PVEAPI.js
> @@ -189,14 +189,26 @@ Ext.onReady(function() {
>
> if (info.returns) {
>
> - var rtype = info.returns.type;
> - if (!rtype && info.returns.items)
> + var retinf = info.returns;
> + var rtype = retinf.type;
> + if (!rtype && retinf.items)
> rtype = 'array';
> if (!rtype)
> rtype = 'object';
>
> + var returnhtml;
> + if (retinf.items) {
> + returnhtml = '<pre>items: ' + JSON.stringify(retinf.items, null, 4) + '</pre>';
> + }
> +
> + if (retinf.properties) {
> + returnhtml = returnhtml || '';
> + returnhtml += '<pre>properties:' + JSON.stringify(retinf.properties, null, 4);
> + }
> +
> sections.push({
> - title: 'Returns: ' + rtype
> + title: 'Returns: ' + rtype,
> + html: returnhtml
> });
> }
>
>
More information about the pve-devel
mailing list