diff --git a/kube-core/src/schema.rs b/kube-core/src/schema.rs index 943c0c3e2..241578fb9 100644 --- a/kube-core/src/schema.rs +++ b/kube-core/src/schema.rs @@ -39,7 +39,7 @@ impl Visitor for StructuralSchemaRewriter { .and_then(|subschemas| subschemas.one_of.as_mut()) { // Tagged enums are serialized using `one_of` - hoist_subschema_properties(one_of, &mut schema.object, &mut schema.instance_type, false); + hoist_subschema_properties(one_of, &mut schema.object, &mut schema.instance_type); } if let Some(any_of) = schema @@ -48,7 +48,7 @@ impl Visitor for StructuralSchemaRewriter { .and_then(|subschemas| subschemas.any_of.as_mut()) { // Untagged enums are serialized using `any_of` - hoist_subschema_properties(any_of, &mut schema.object, &mut schema.instance_type, true); + hoist_subschema_properties(any_of, &mut schema.object, &mut schema.instance_type); } // check for maps without with properties (i.e. flattened maps) @@ -72,7 +72,6 @@ fn hoist_subschema_properties( subschemas: &mut Vec, common_obj: &mut Option>, instance_type: &mut Option>, - allow_if_equal: bool, ) { let common_obj = common_obj.get_or_insert_with(|| Box::new(ObjectValidation::default())); @@ -106,21 +105,12 @@ fn hoist_subschema_properties( entry.insert(property); } Entry::Occupied(entry) => { - if allow_if_equal { - if &property == entry.get() { - continue; - } - + if &property != entry.get() { panic!("Property {:?} has the schema {:?} but was already defined as {:?} in another subschema. The schemas for a property used in multiple subschemas must be identical", - entry.key(), - &property, - entry.get()); + entry.key(), + &property, + entry.get()); } - - panic!( - "Property {:?} was already defined in another subschema", - entry.key() - ) } } }