[pve-devel] applied: [PATCH pve-common] api_dump_full: use api_clone_schema() for 'returns' schema

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Sep 13 13:03:06 CEST 2018


On 9/13/18 12:53 PM, Dietmar Maurer wrote:
> This  convert indexed parameters like -net\d+ to -net[n], so resulting dump
> is smaller.
> 

applied, thanks!

> Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
> ---
>  src/PVE/RESTHandler.pm | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm
> index ed76863..f645f1b 100644
> --- a/src/PVE/RESTHandler.pm
> +++ b/src/PVE/RESTHandler.pm
> @@ -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;
>  			}
> 




More information about the pve-devel mailing list