From: Shannon Sterz <s.sterz@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox 4/4] docgen: add a stop-gap fix to allow generating schema for pve-api-types
Date: Wed, 12 Nov 2025 11:24:12 +0100 [thread overview]
Message-ID: <20251112102415.175358-6-s.sterz@proxmox.com> (raw)
In-Reply-To: <20251112102415.175358-1-s.sterz@proxmox.com>
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-docgen/src/lib.rs | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/proxmox-docgen/src/lib.rs b/proxmox-docgen/src/lib.rs
index 67d502d5..f3d53519 100644
--- a/proxmox-docgen/src/lib.rs
+++ b/proxmox-docgen/src/lib.rs
@@ -97,7 +97,7 @@ fn dump_schema(schema: &Schema) -> Value {
}
}
Schema::Object(object_schema) => {
- data = dump_property_schema(object_schema);
+ data = dump_property_schema(object_schema, false);
data["type"] = "object".into();
if let Some(default_key) = object_schema.default_key {
data["default_key"] = default_key.into();
@@ -117,7 +117,12 @@ fn dump_schema(schema: &Schema) -> Value {
}
}
Schema::AllOf(alloff_schema) => {
- data = dump_property_schema(alloff_schema);
+ let dirty_allof = alloff_schema
+ .list
+ .iter()
+ .any(|schema| schema.any_object().is_none());
+
+ data = dump_property_schema(alloff_schema, dirty_allof);
data["type"] = "object".into();
}
Schema::OneOf(schema) => {
@@ -144,7 +149,8 @@ fn dump_schema(schema: &Schema) -> Value {
data
}
-fn dump_property_schema(param: &dyn ObjectSchemaType) -> Value {
+// TODO: remove `dirty_allof` again once pve-api-types generates proper `AllOf` schema.
+fn dump_property_schema(param: &dyn ObjectSchemaType, dirty_allof: bool) -> Value {
let mut properties = json!({});
for (prop, optional, schema) in param.properties() {
@@ -155,13 +161,23 @@ fn dump_property_schema(param: &dyn ObjectSchemaType) -> Value {
properties[prop] = property;
}
- let data = json!({
- "description": param.description(),
- "additionalProperties": param.additional_properties(),
- "properties": properties,
- });
-
- data
+ if dirty_allof {
+ json!({
+ "description": param.description(),
+ // stop gap for now. pve-api-types generates certain properties as string schema that
+ // are really property strings (which wrap an object schema anyway). however,
+ // `additional_properties()` panics there, because it will expect *only* object
+ // schema.
+ "additionalProperties": true,
+ "properties": properties,
+ })
+ } else {
+ json!({
+ "description": param.description(),
+ "additionalProperties": param.additional_properties(),
+ "properties": properties,
+ })
+ }
}
fn dump_api_permission(permission: &Permission, privileges: &[(&str, u64)]) -> Value {
@@ -222,7 +238,7 @@ fn dump_api_method_schema(
"description": api_method.parameters.description(),
});
- data["parameters"] = dump_property_schema(&api_method.parameters);
+ data["parameters"] = dump_property_schema(&api_method.parameters, false);
let mut returns = dump_schema(api_method.returns.schema);
if api_method.returns.optional {
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-11-12 10:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 10:24 [pdm-devel] [PATCH datacenter-manager/proxmox{, -backup}/widget-toolkit 0/8] unstable flag and pdm api viewer Shannon Sterz
2025-11-12 10:24 ` [pdm-devel] [PATCH widget-toolkit 1/1] api viewer: add support for endpoints that are marked as unstable Shannon Sterz
2025-11-12 10:24 ` [pdm-devel] [PATCH proxmox 1/4] router/api-macro: add unstable flag for ApiMethod Shannon Sterz
2025-11-12 10:24 ` [pdm-devel] [PATCH proxmox 2/4] docgen: add docgen crate Shannon Sterz
2025-11-12 10:24 ` [pdm-devel] [PATCH proxmox 3/4] docgen: add support for the new stable flag Shannon Sterz
2025-11-12 10:24 ` Shannon Sterz [this message]
2025-11-12 16:09 ` [pdm-devel] [PATCH proxmox 4/4] docgen: add a stop-gap fix to allow generating schema for pve-api-types Shannon Sterz
2025-11-12 10:24 ` [pdm-devel] [PATCH proxmox-backup 1/1] docgen: use proxmox-rs docgen crate Shannon Sterz
2025-11-12 10:24 ` [pdm-devel] [PATCH datacenter-manager 1/2] docgen: switch to " Shannon Sterz
2025-11-12 10:24 ` [pdm-devel] [PATCH datacenter-manager 2/2] api-viewer: add an api-viewer package Shannon Sterz
2025-11-13 12:02 ` [pdm-devel] Superseded: Re: [PATCH datacenter-manager/proxmox{, -backup}/widget-toolkit 0/8] unstable flag and pdm api viewer Shannon Sterz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251112102415.175358-6-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox