* [pdm-devel] [PATCH proxmox] Schema2Rust: handle missing parameters->properties
@ 2025-09-26 12:59 Hannes Laimer
2025-10-17 13:46 ` [pdm-devel] applied: " Wolfgang Bumiller
0 siblings, 1 reply; 2+ messages in thread
From: Hannes Laimer @ 2025-09-26 12:59 UTC (permalink / raw)
To: pdm-devel
We crashed if we encountered
```
parameters => {
additionalProperties => 0,
},
```
almost all endpoint specify this explicitly, so
```
parameters => {
additionalProperties => 0,
properties => {},
},
```
I found at least these
- `/cluster/firewall/options`
- `/cluster/firewall/macros`
to be exceptions to this, there may be more.
Our api-macro does also not need this to be specified explicitly,
therefore we have the generator infer `properties => {}` in case it is
not specified explicitly, i.e. it is missing.
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
pve-api-types/generator-lib/Schema2Rust.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pve-api-types/generator-lib/Schema2Rust.pm b/pve-api-types/generator-lib/Schema2Rust.pm
index 0f3efc0a..7d600ae7 100644
--- a/pve-api-types/generator-lib/Schema2Rust.pm
+++ b/pve-api-types/generator-lib/Schema2Rust.pm
@@ -1561,13 +1561,13 @@ my sub method_parameters : prototype($$$$$) {
my $url_params = url_parameters($api_url);
- my $parameters = $api_method->{parameters};
+ my $parameters = $api_method->{parameters} // {};
#print "URL PARAMETERS: ".join(', ', $url_params->@*)."\n";
# Clone to avoid modifying the duplicate.
$parameters = { $parameters->%* };
- my $properties = { $parameters->{properties}->%* };
+ my $properties = { ($parameters->{properties} // {})->%* };
$parameters->{properties} = $properties;
# Handle URL parameter types. These should only be strings or integers.
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pdm-devel] applied: [PATCH proxmox] Schema2Rust: handle missing parameters->properties
2025-09-26 12:59 [pdm-devel] [PATCH proxmox] Schema2Rust: handle missing parameters->properties Hannes Laimer
@ 2025-10-17 13:46 ` Wolfgang Bumiller
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2025-10-17 13:46 UTC (permalink / raw)
To: Hannes Laimer; +Cc: pdm-devel
applied, thanks
On Fri, Sep 26, 2025 at 02:59:40PM +0200, Hannes Laimer wrote:
> We crashed if we encountered
> ```
> parameters => {
> additionalProperties => 0,
> },
> ```
> almost all endpoint specify this explicitly, so
> ```
> parameters => {
> additionalProperties => 0,
> properties => {},
> },
> ```
> I found at least these
> - `/cluster/firewall/options`
> - `/cluster/firewall/macros`
> to be exceptions to this, there may be more.
>
> Our api-macro does also not need this to be specified explicitly,
> therefore we have the generator infer `properties => {}` in case it is
> not specified explicitly, i.e. it is missing.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> pve-api-types/generator-lib/Schema2Rust.pm | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/pve-api-types/generator-lib/Schema2Rust.pm b/pve-api-types/generator-lib/Schema2Rust.pm
> index 0f3efc0a..7d600ae7 100644
> --- a/pve-api-types/generator-lib/Schema2Rust.pm
> +++ b/pve-api-types/generator-lib/Schema2Rust.pm
> @@ -1561,13 +1561,13 @@ my sub method_parameters : prototype($$$$$) {
>
> my $url_params = url_parameters($api_url);
>
> - my $parameters = $api_method->{parameters};
> + my $parameters = $api_method->{parameters} // {};
>
> #print "URL PARAMETERS: ".join(', ', $url_params->@*)."\n";
>
> # Clone to avoid modifying the duplicate.
> $parameters = { $parameters->%* };
> - my $properties = { $parameters->{properties}->%* };
> + my $properties = { ($parameters->{properties} // {})->%* };
> $parameters->{properties} = $properties;
>
> # Handle URL parameter types. These should only be strings or integers.
> --
> 2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-17 13:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-26 12:59 [pdm-devel] [PATCH proxmox] Schema2Rust: handle missing parameters->properties Hannes Laimer
2025-10-17 13:46 ` [pdm-devel] applied: " Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox