[pve-devel] [PATCH pve-common 5/6] JSONSchema::generate_typetext: default_key support

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Sep 22 13:45:43 CEST 2015


---
 src/PVE/JSONSchema.pm | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 0d68608..3afc37a 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -1357,13 +1357,17 @@ sub generate_typetext {
     my ($pre, $post) = ('', '');
     my $add = sub {
 	my ($key) = @_;
-	if (my $desc = $schema->{$key}->{format_description}) {
-	    $typetext .= "$pre$key=<$desc>$post";
-	} elsif (my $text = $schema->{$key}->{typetext}) {
-	    $typetext .= "$pre$text$post";
+	$typetext .= $pre;
+	my $entry = $schema->{$key};
+	if (my $desc = $entry->{format_description}) {
+	    $typetext .= $entry->{default_key} ? "[$key=]" : "$key=";
+	    $typetext .= "<$desc>";
+	} elsif (my $text = $entry->{typetext}) {
+	    $typetext .= $text;
 	} else {
 	    die "internal error: neither format_description nor typetext found";
 	}
+	$typetext .= $post;
     };
     foreach my $key (@required) {
 	&$add($key);
-- 
2.1.4





More information about the pve-devel mailing list