more pg try catching and error handling
This commit is contained in:
@ -507,10 +507,8 @@ impl Schema {
|
||||
let mut parent_type_name = None;
|
||||
if let Some(family) = &self.obj.family {
|
||||
parent_type_name = Some(family.split('.').next_back().unwrap_or(family).to_string());
|
||||
} else if let Some(id) = &self.obj.id {
|
||||
parent_type_name = Some(id.split('.').next_back().unwrap_or("").to_string());
|
||||
} else if let Some(ref_id) = &self.obj.r#ref {
|
||||
parent_type_name = Some(ref_id.split('.').next_back().unwrap_or("").to_string());
|
||||
} else if let Some(identifier) = self.obj.identifier() {
|
||||
parent_type_name = Some(identifier);
|
||||
}
|
||||
|
||||
if let Some(p_type) = parent_type_name {
|
||||
@ -531,12 +529,12 @@ impl Schema {
|
||||
|
||||
if let Some(family) = &target_schema.obj.family {
|
||||
child_type_name = Some(family.split('.').next_back().unwrap_or(family).to_string());
|
||||
} else if let Some(ref_id) = target_schema.obj.r#ref.as_ref() {
|
||||
child_type_name = Some(ref_id.split('.').next_back().unwrap_or("").to_string());
|
||||
} else if let Some(ref_id) = target_schema.obj.identifier() {
|
||||
child_type_name = Some(ref_id);
|
||||
} else if let Some(arr) = &target_schema.obj.one_of {
|
||||
if let Some(first) = arr.first() {
|
||||
if let Some(ref_id) = first.obj.id.as_ref().or(first.obj.r#ref.as_ref()) {
|
||||
child_type_name = Some(ref_id.split('.').next_back().unwrap_or("").to_string());
|
||||
if let Some(ref_id) = first.obj.identifier() {
|
||||
child_type_name = Some(ref_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -697,6 +695,16 @@ impl<'de> Deserialize<'de> for Schema {
|
||||
}
|
||||
}
|
||||
|
||||
impl SchemaObject {
|
||||
pub fn identifier(&self) -> Option<String> {
|
||||
if let Some(lookup_key) = self.id.as_ref().or(self.r#ref.as_ref()) {
|
||||
Some(lookup_key.split('.').next_back().unwrap_or("").to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum SchemaTypeOrArray {
|
||||
|
||||
Reference in New Issue
Block a user