]> git.proxmox.com Git - proxmox.git/commitdiff
schema: AllOf/OneOf: actually perform additional_properties() check
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 21 Feb 2024 10:41:53 +0000 (11:41 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 21 Feb 2024 10:43:20 +0000 (11:43 +0100)
rather than just always allowing additional properties, only return
true if any of the available schemas allows it

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
proxmox-schema/src/schema.rs

index 2377718e1f812261d682493d954a201641bdf1d7..257cedc8954a457854296b0b133ca8bbbe77fcee 100644 (file)
@@ -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> {