diff --git a/xsd-parser/src/generator/enum_case.rs b/xsd-parser/src/generator/enum_case.rs index a5580db8..cc77ce05 100644 --- a/xsd-parser/src/generator/enum_case.rs +++ b/xsd-parser/src/generator/enum_case.rs @@ -1,8 +1,10 @@ use crate::{ - generator::{default::default_format_type, utils::split_name, Generator}, + generator::{utils::split_name, Generator}, parser::types::{EnumCase, EnumSource}, }; +use super::utils::{filter_type_name, sanitize}; + pub trait EnumCaseGenerator { fn generate(&self, entity: &EnumCase, gen: &Generator) -> String { let typename = if entity.type_name.is_some() { @@ -20,12 +22,10 @@ pub trait EnumCaseGenerator { ) } - fn get_name(&self, entity: &EnumCase, gen: &Generator) -> String { - default_format_type(entity.name.as_str(), &gen.target_ns.borrow()) - .split("::") - .last() - .unwrap() - .to_string() + fn get_name(&self, entity: &EnumCase, _: &Generator) -> String { + sanitize(filter_type_name( + &entity.name.split(':').last().unwrap_or(&entity.name.to_owned()), + )) } fn get_type_name(&self, entity: &EnumCase, gen: &Generator) -> String {