[pdm-devel] [PATCH proxmox 3/5] pve-api-types: schema2rust: handle `macro` keyword like we do `type`
Hannes Laimer
h.laimer at proxmox.com
Thu Oct 30 15:33:56 CET 2025
Firewall rules have a field named `macro`, this would trip up the
generated rust code. This fixes that.
Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
pve-api-types/generator-lib/Schema2Rust.pm | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/pve-api-types/generator-lib/Schema2Rust.pm b/pve-api-types/generator-lib/Schema2Rust.pm
index c9fba231..f54b3683 100644
--- a/pve-api-types/generator-lib/Schema2Rust.pm
+++ b/pve-api-types/generator-lib/Schema2Rust.pm
@@ -126,8 +126,8 @@ sub api_to_string : prototype($$$$$) {
local $API_TYPE_POS = "$API_TYPE_POS/$key";
- # We need to quote keys with hyphens:
- my $safe_key = ($key =~ /-/) ? "\"$key\"" : $key;
+ # We need to quote keys with hyphens or reserved keywords:
+ my $safe_key = (($key =~ /-/) || ($key eq 'macro')) ? "\"$key\"" : $key;
if (exists($API_TYPE_OVERRIDES{$API_TYPE_POS})) {
$value = $API_TYPE_OVERRIDES{$API_TYPE_POS};
@@ -172,7 +172,7 @@ sub api_to_string : prototype($$$$$) {
warn "api type extension for $API_TYPE_POS.$key already in schema, skipping\n";
next;
}
- my $safe_key = ($key =~ /-/) ? "\"$key\"" : $key;
+ my $safe_key = (($key =~ /-/) || ($key eq 'macro')) ? "\"$key\"" : $key;
my $value = $extra->{$key};
print {$out} "${indent}$safe_key: $value,\n";
}
@@ -726,6 +726,7 @@ sub namify_field : prototype($) {
}
return 'ty' if $out eq 'type';
+ return 'r#macro' if $out eq 'macro';
return $out;
}
--
2.47.3
More information about the pdm-devel
mailing list