removed schema realms, fixed fixture generations, added dynamic type resolution for validation based on type and kind discriminators for filters
This commit is contained in:
@ -74,8 +74,8 @@ impl Schema {
|
||||
);
|
||||
|
||||
let mut wrapper_obj = SchemaObject::default();
|
||||
// Conceptually link this directly into the STI lineage of the base `filter` object
|
||||
wrapper_obj.type_ = Some(SchemaTypeOrArray::Single("filter".to_string()));
|
||||
// Filters are just plain objects containing conditions, no inheritance required
|
||||
wrapper_obj.type_ = Some(SchemaTypeOrArray::Single("object".to_string()));
|
||||
wrapper_obj.properties = Some(filter_props);
|
||||
|
||||
return Some(Schema {
|
||||
|
||||
@ -51,8 +51,8 @@ impl Schema {
|
||||
|
||||
// 1. Resolve INHERITANCE dependencies first
|
||||
if let Some(crate::database::object::SchemaTypeOrArray::Single(t)) = &self.obj.type_ {
|
||||
if !crate::database::object::is_primitive_type(t) {
|
||||
if let Some(parent) = db.get_scoped_schema(crate::database::realm::SchemaRealm::Type, t) {
|
||||
if !crate::database::object::is_primitive_type(t) && !t.starts_with('$') {
|
||||
if let Some(parent) = db.schemas.get(t).cloned() {
|
||||
parent.as_ref().compile(db, t, t.clone(), errors);
|
||||
if let Some(p_props) = parent.obj.compiled_properties.get() {
|
||||
props.extend(p_props.clone());
|
||||
@ -85,8 +85,8 @@ impl Schema {
|
||||
}
|
||||
|
||||
for t in types {
|
||||
if !crate::database::object::is_primitive_type(t) {
|
||||
if let Some(parent) = db.get_scoped_schema(crate::database::realm::SchemaRealm::Type, t) {
|
||||
if !crate::database::object::is_primitive_type(t) && !t.starts_with('$') {
|
||||
if let Some(parent) = db.schemas.get(t).cloned() {
|
||||
parent.as_ref().compile(db, t, t.clone(), errors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,10 @@ impl Schema {
|
||||
let mut strategy = String::new();
|
||||
|
||||
if let Some(family) = &self.obj.family {
|
||||
// Formalize the <Variant>.<Base> topology
|
||||
// family_base extracts the 'Base' (e.g. 'widget', 'person')
|
||||
let family_base = family.split('.').next_back().unwrap_or(family).to_string();
|
||||
// family_prefix extracts the 'Variant' (e.g. 'stock', 'light')
|
||||
let family_prefix = family
|
||||
.strip_suffix(&family_base)
|
||||
.unwrap_or("")
|
||||
@ -29,7 +32,7 @@ impl Schema {
|
||||
format!("{}.{}", family_prefix, var)
|
||||
};
|
||||
|
||||
if db.get_scoped_schema(crate::database::realm::SchemaRealm::Type, &target_id).is_some() {
|
||||
if db.schemas.get(&target_id).is_some() {
|
||||
options.insert(var.to_string(), (None, Some(target_id)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user