From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id EC8AE1FF179 for ; Wed, 12 Nov 2025 17:09:29 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D641A8D47; Wed, 12 Nov 2025 17:10:16 +0100 (CET) Mime-Version: 1.0 Date: Wed, 12 Nov 2025 17:09:43 +0100 Message-Id: To: "Shannon Sterz" X-Mailer: aerc 0.20.0 References: <20251112102415.175358-1-s.sterz@proxmox.com> <20251112102415.175358-6-s.sterz@proxmox.com> In-Reply-To: <20251112102415.175358-6-s.sterz@proxmox.com> From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762963757965 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.062 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lib.rs] Subject: Re: [pdm-devel] [PATCH proxmox 4/4] docgen: add a stop-gap fix to allow generating schema for pve-api-types X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Cc: pdm-devel@lists.proxmox.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" note that Wolfgang is already working on a fix for this, so this commit can just be dropped. since it's just about dropping this commit, i'll refrain from respin this series just for that change. hope that's ok, if not let me know. On Wed Nov 12, 2025 at 11:24 AM CET, Shannon Sterz wrote: > Signed-off-by: Shannon Sterz > --- > 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 { _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel