Skip to content

Commit

Permalink
Stop pascalizing enum case name to avoid clashes
Browse files Browse the repository at this point in the history
Pascalizing enum case names in restrictions can cause clashes (see lumeohq#154)
  • Loading branch information
lkirkwood committed Apr 20, 2024
1 parent 80050d9 commit 3f4485d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions xsd-parser/src/generator/enum_case.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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 {
Expand Down

0 comments on commit 3f4485d

Please sign in to comment.