[pdm-devel] [PATCH proxmox-api-types 1/1] generator: support methods with no parameters
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Feb 5 14:03:55 CET 2025
On Tue, Feb 04, 2025 at 02:14:49PM +0100, Stefan Hanreich wrote:
> Some methods (e.g. 'PUT cluster/sdn') do not take any input
> parameters. Support those methods by generating them with unit type as
> type for the input parameters.
>
> Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
> ---
> pve-api-types/generator-lib/Schema2Rust.pm | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/pve-api-types/generator-lib/Schema2Rust.pm b/pve-api-types/generator-lib/Schema2Rust.pm
> index 068517e..554341d 100644
> --- a/pve-api-types/generator-lib/Schema2Rust.pm
> +++ b/pve-api-types/generator-lib/Schema2Rust.pm
> @@ -535,7 +535,8 @@ my sub print_method_with_body : prototype($$$$$) {
> my ($arg, $def) = @$url_arg;
> print {$out} " $arg: $def->{type},\n";
> }
> - print {$out} " params: $def->{input_type},\n";
> + my $input = $def->{input_type} // '()';
> + print {$out} " params: $input,\n";
This would produce an explicit parameter of type `()` - why not just
drop `params` when we have none?
> my $output = $def->{output_type} // '()';
> print {$out} ") -> Result<$output, Error> {\n";
> if ($trait) {
> --
> 2.39.5
More information about the pdm-devel
mailing list