X-Git-Url: https://git.proxmox.com/?p=pve-docs.git;a=blobdiff_plain;f=extractapi.pl;h=06d6af4cb2cabe8bbdf514ed03046879bf53c15b;hp=0488ea940ad54ed6802e098a98278f0c17c61301;hb=00821894522d1afca5cedbb34bb8e20992bd7161;hpb=61568a650e854d54d5c1920d305ac46aa9d47d04 diff --git a/extractapi.pl b/extractapi.pl index 0488ea9..06d6af4 100755 --- a/extractapi.pl +++ b/extractapi.pl @@ -1,44 +1,15 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; +use warnings; + use PVE::RESTHandler; use PVE::API2; use JSON; -sub cleanup_tree { - my ($h) = @_; - - my $class = ref($h); - return $h if !$class; - - if ($class eq 'ARRAY') { - my $res = []; - foreach my $el (@$h) { - push @$res, cleanup_tree($el); - } - return $res; - } elsif ($class eq 'HASH') { - my $res = {}; - foreach my $k (keys %$h) { - if (my $class = ref($h->{$k})) { - if ($class eq 'CODE') { - next if $k eq 'completion'; - } - $res->{$k} = cleanup_tree($h->{$k}); - } else { - $res->{$k} = $h->{$k}; - } - } - return $res; - } elsif ($class eq 'Regexp') { - return "$h"; # return string representation - } else { - die "unknown class '$class'\n"; - } -} -my $tree = cleanup_tree(PVE::RESTHandler::api_dump('PVE::API2')); +my $tree = PVE::RESTHandler::api_dump_remove_refs(PVE::RESTHandler::api_dump('PVE::API2')); -print "var pveapi = " . to_json($tree, {pretty => 1}) . ";\n\n"; +print "var pveapi = " . to_json($tree, {pretty => 1, canonical => 1}) . ";\n\n"; exit(0);