in compiler-rs/openapi_to_clients_schema/src/openapi.rs [96:149]
fn merge_in_any(&self, acc: AnySchema, schema: &ReferenceOr<Schema>) -> anyhow::Result<AnySchema> {
let schema = self.get_schema(schema)?;
match &schema.schema_kind {
SchemaKind::AllOf { all_of } | SchemaKind::Any(AnySchema { all_of, .. }) if !all_of.is_empty() => {
let mut result = acc;
for schema in all_of {
result = self.merge_in_any(result, schema)?;
}
return Ok(result);
}
_ => {}
}
let schema = schema_to_any(&schema.schema_kind)?;
let result = AnySchema {
typ: merge_option(acc.typ, schema.typ)?,
any_of: merge_vec(acc.any_of, schema.any_of),
one_of: merge_vec(acc.one_of, schema.one_of),
all_of: merge_vec(acc.all_of, schema.all_of),
not: merge_option(acc.not, schema.not)?,
// Structure properties
additional_properties: merge_option(acc.additional_properties, schema.additional_properties)?,
items: merge_option(acc.items, schema.items)?,
unique_items: merge_option(acc.unique_items, schema.unique_items)?,
properties: Default::default(),
max_properties: merge_option(acc.max_properties, schema.max_properties)?,
min_properties: merge_option(acc.min_properties, schema.min_properties)?,
// Scalar properties
required: merge_vec(acc.required, schema.required),
format: merge_option(acc.format, schema.format)?,
exclusive_maximum: merge_option(acc.exclusive_maximum, schema.exclusive_maximum)?,
exclusive_minimum: merge_option(acc.exclusive_minimum, schema.exclusive_minimum)?,
maximum: merge_option(acc.maximum, schema.maximum)?,
max_items: merge_option(acc.max_items, schema.max_items)?,
max_length: merge_option(acc.max_length, schema.max_length)?,
minimum: merge_option(acc.minimum, schema.minimum)?,
min_items: merge_option(acc.min_items, schema.min_items)?,
min_length: merge_option(acc.min_length, schema.min_length)?,
pattern: merge_option(acc.pattern, schema.pattern)?,
multiple_of: merge_option(acc.multiple_of, schema.multiple_of)?,
enumeration: merge_vec(acc.enumeration, schema.enumeration),
};
Ok(result)
}