From bae2cf75de2d158798736ba064cb15f8c3f08eb4 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 21 Feb 2024 11:41:53 +0100 Subject: [PATCH] schema: AllOf/OneOf: actually perform additional_properties() check rather than just always allowing additional properties, only return true if any of the available schemas allows it Signed-off-by: Wolfgang Bumiller --- proxmox-schema/src/schema.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/proxmox-schema/src/schema.rs b/proxmox-schema/src/schema.rs index 2377718e..257cedc8 100644 --- a/proxmox-schema/src/schema.rs +++ b/proxmox-schema/src/schema.rs @@ -917,7 +917,12 @@ impl ObjectSchemaType for AllOfSchema { } fn additional_properties(&self) -> bool { - true + self.list.iter().any(|schema| { + schema + .any_object() + .expect("non-object-schema in `AllOfSchema`") + .additional_properties() + }) } fn default_key(&self) -> Option<&'static str> { @@ -988,7 +993,12 @@ impl ObjectSchemaType for OneOfSchema { } fn additional_properties(&self) -> bool { - true + self.list.iter().any(|(_, schema)| { + schema + .any_object() + .expect("non-object-schema in `OneOfSchema`") + .additional_properties() + }) } fn default_key(&self) -> Option<&'static str> {