]> git.proxmox.com Git - pve-common.git/commitdiff
api_dump_full: use api_clone_schema() for 'returns' schema
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 13 Sep 2018 10:53:36 +0000 (12:53 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 13 Sep 2018 11:00:05 +0000 (13:00 +0200)
This  convert indexed parameters like -net\d+ to -net[n], so resulting dump
is smaller.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
src/PVE/RESTHandler.pm

index ed7686324ec4f9127fd852fa95330d346aaedcde..f645f1b889df16edc6a8d27049fa2e14c121d800 100644 (file)
@@ -45,7 +45,7 @@ our $standard_output_options = {
 };
 
 sub api_clone_schema {
-    my ($schema) = @_;
+    my ($schema, $no_typetext) = @_;
 
     my $res = {};
     my $ref = ref($schema);
@@ -71,7 +71,7 @@ sub api_clone_schema {
            my $tmp = ref($pd) ? clone($pd) : $pd;
            # NOTE: add typetext property for more complex types, to
            # make the web api viewer code simpler
-           if (!(defined($tmp->{enum}) || defined($tmp->{pattern}))) {
+           if (!$no_typetext && !(defined($tmp->{enum}) || defined($tmp->{pattern}))) {
                my $typetext = PVE::JSONSchema::schema_get_type_text($tmp);
                if ($tmp->{type} && ($tmp->{type} ne $typetext)) {
                    $tmp->{typetext} = $typetext;
@@ -143,6 +143,8 @@ sub api_dump_full {
                    } else {
                        if ($k eq 'parameters') {
                            $data->{$k} = api_clone_schema($d);
+                       } elsif ($k eq 'returns') {
+                           $data->{$k} = api_clone_schema($d, 1);
                        } else {
                            $data->{$k} = ref($d) ? clone($d) : $d;
                        }