mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-08 17:58:53 +00:00
print api res: always allow result to be undef if optional
If the return schema says that it's optionally returns something then we want to allow returning nothing, i.e., undef Co-developed-by: Dominic Jäger <d.jaeger@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
b610385849
commit
c0b8717c44
@ -413,6 +413,7 @@ sub print_api_result {
|
|||||||
|
|
||||||
if ($result_schema && defined($result_schema->{type})) {
|
if ($result_schema && defined($result_schema->{type})) {
|
||||||
return if $result_schema->{type} eq 'null';
|
return if $result_schema->{type} eq 'null';
|
||||||
|
return if $result_schema->{optional} && !defined($data);
|
||||||
} else {
|
} else {
|
||||||
my $type = $guess_type->($data);
|
my $type = $guess_type->($data);
|
||||||
$result_schema = { type => $type };
|
$result_schema = { type => $type };
|
||||||
|
Loading…
Reference in New Issue
Block a user