With 1.97 I have a <xsd:element name="COMMENT" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/> that gets turned into repeated string c_o_m_m_e_n_t, but I would expect repeated string comment.
Looks like the current code assumes element names are in camel case. Here is a patch to use getCaseFormatName(...) to figure out which case convention is used. I changed \w+ to \w* so that names like abc3 are treated as camel case.
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java
index 2b5cc93..1272253 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java
@@ -565,13 +565,13 @@ public class ProtoSerializer {
}
} else {
if (Character.isLowerCase(s.charAt(0))) {
- if (s.matches("([a-z]+[A-Z0-9]+\\w+)+")) {
+ if (s.matches("([a-z]+[A-Z0-9]+\\w*)+")) {
return CaseFormat.LOWER_CAMEL;
} else if (s.matches("[a-z]+")) {
return CaseFormat.LOWER_UNDERSCORE;
}
} else {
- if (s.matches("([A-Z]+[a-z0-9]+\\w+)+")) {
+ if (s.matches("([A-Z]+[a-z0-9]+\\w*)+")) {
return CaseFormat.UPPER_CAMEL;
} else if (s.matches("[A-Z]+")) {
return CaseFormat.UPPER_UNDERSCORE;
@@ -1158,7 +1158,7 @@ public class ProtoSerializer {
String strippedFieldName = StringUtils.removeEnd(StringUtils.removeStart(fieldName, UNDERSCORE), UNDERSCORE);
- String newFieldName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, strippedFieldName);
+ String newFieldName = getCaseFormatName(strippedFieldName).to(CaseFormat.LOWER_UNDERSCORE, strippedFieldName);
// Remove all dashes
newFieldName = StringUtils.remove(newFieldName, DASH);
With 1.97 I have a
<xsd:element name="COMMENT" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>that gets turned intorepeated string c_o_m_m_e_n_t, but I would expectrepeated string comment.Looks like the current code assumes element names are in camel case. Here is a patch to use
getCaseFormatName(...)to figure out which case convention is used. I changed\w+to\w*so that names likeabc3are treated as camel case.