]> git.proxmox.com Git - pmg-docs.git/commitdiff
api-viewer: show full return info if available
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 21 Mar 2018 14:53:38 +0000 (15:53 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 22 Mar 2018 12:52:05 +0000 (13:52 +0100)
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@proxmox.com>
api-viewer/PMGAPI.js

index bcd703b979889c25530a1358c53c1c07f80d1da0..e4504af545e6edbd566305571f4aef7e864e6b91 100644 (file)
@@ -189,15 +189,28 @@ 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';
 
-                   sections.push({
-                       title: 'Returns: ' + rtype
-                   });
+                   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,
+                      bodyPadding: 10,
+                      html: returnhtml
+                  });
                }
 
                var permhtml = '';