X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FJSONSchema.pm;h=fe6614ac57b86cae287c5757c169e01558fd73a6;hp=caeefe2c6b61a108f6dedfdc7972633080543cb2;hb=25d9bda94127b1a91181cd80bb9948093dea389b;hpb=b54ad320a5165dddc28272279d34183a6533928c diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index caeefe2..fe6614a 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -506,6 +506,17 @@ sub parse_property_string { # In property strings we default to not allowing additional properties $additional_properties = 0 if !defined($additional_properties); + # Support named formats here, too: + if (!ref($format)) { + if (my $desc = $format_list->{$format}) { + $format = $desc; + } else { + die "unknown format: $format\n"; + } + } elsif (ref($format) ne 'HASH') { + die "unexpected format value of type ".ref($format)."\n"; + } + my $default_key; my $res = {}; @@ -720,7 +731,7 @@ sub check_object { check_prop($value, $requires, $path, $errors); } elsif (!defined($value->{$requires})) { add_error($errors, $path ? "$path.$requires" : $requires, - "missing property - '$newpath' requiers this property"); + "missing property - '$newpath' requires this property"); } } @@ -1672,18 +1683,18 @@ sub schema_get_type_text { } elsif ($phash->{format_description}) { return "<$phash->{format_description}>"; } elsif ($phash->{enum}) { - return "(" . join(' | ', sort @{$phash->{enum}}) . ")"; + return "<" . join(' | ', sort @{$phash->{enum}}) . ">"; } elsif ($phash->{pattern}) { return $phash->{pattern}; } elsif ($type eq 'integer' || $type eq 'number') { # NOTE: always access values as number (avoid converion to string) if (defined($phash->{minimum}) && defined($phash->{maximum})) { - return "$type (" . ($phash->{minimum} + 0) . " - " . + return "<$type> (" . ($phash->{minimum} + 0) . " - " . ($phash->{maximum} + 0) . ")"; } elsif (defined($phash->{minimum})) { - return "$type (" . ($phash->{minimum} + 0) . " - N)"; + return "<$type> (" . ($phash->{minimum} + 0) . " - N)"; } elsif (defined($phash->{maximum})) { - return "$type (-N - " . ($phash->{maximum} + 0) . ")"; + return "<$type> (-N - " . ($phash->{maximum} + 0) . ")"; } } elsif ($type eq 'string') { if (my $format = $phash->{format}) { @@ -1694,7 +1705,7 @@ sub schema_get_type_text { } } - return $type; + return "<$type>"; } 1;