]> git.proxmox.com Git - pve-common.git/commitdiff
add typetext property for more complex types
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 5 Sep 2016 05:47:32 +0000 (07:47 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 5 Sep 2016 05:47:32 +0000 (07:47 +0200)
src/PVE/RESTHandler.pm

index 0b8b81c6d740854c72e5b42fc2709de513b786d3..fc220a6018481d48bc2ab75b8aa39eb3728964b2 100644 (file)
@@ -40,7 +40,16 @@ sub api_clone_schema {
                    next; # only handle once for -xx0, but only if -xx0 exists
                }
            }
                    next; # only handle once for -xx0, but only if -xx0 exists
                }
            }
-           $res->{$k}->{$p} = ref($pd) ? clone($pd) : $pd;
+           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}))) {
+               my $typetext = PVE::JSONSchema::schema_get_type_text($tmp);
+               if ($tmp->{type} && ($tmp->{type} ne $typetext)) {
+                   $tmp->{typetext} = $typetext;
+               }
+           }
+           $res->{$k}->{$p} = $tmp;
        }
     }
 
        }
     }