Skip to content

Commit

Permalink
Remove allow_if_equal flag
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
  • Loading branch information
sbernauer committed Oct 7, 2022
1 parent 9840511 commit 7d6ee75
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions kube-core/src/schema.rs
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -72,7 +72,6 @@ fn hoist_subschema_properties(
subschemas: &mut Vec<Schema>,
common_obj: &mut Option<Box<ObjectValidation>>,
instance_type: &mut Option<SingleOrVec<InstanceType>>,
allow_if_equal: bool,
) {
let common_obj = common_obj.get_or_insert_with(|| Box::new(ObjectValidation::default()));

Expand Down Expand Up @@ -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()
)
}
}
}
Expand Down

0 comments on commit 7d6ee75

Please sign in to comment.