@@ -312,7 +312,20 @@ async function asObjectiveCType(type, cluster, options) {
312312}
313313
314314function asStructPropertyName ( prop ) {
315- prop = appHelper . asLowerCamelCase ( prop ) ;
315+ prop = appHelper . asLowerCamelCase ( prop , { hash : { preserveAcronyms : true } } ) ;
316+
317+ // If prop is now all-uppercase (which can happen, because we are preserving
318+ // acronyms), lowercase it.
319+ if ( prop . match ( / ^ [ A - Z 0 - 9 ] + $ / ) ) {
320+ prop = prop . toLowerCase ( ) ;
321+ }
322+
323+ // If prop is now all-uppercase, with at least two capital letters followed by
324+ // a lowercase "s" (probably acronym being pluralized), just lowercase the
325+ // whole thing.
326+ if ( prop . match ( / ^ [ A - Z ] [ A - Z ] + s $ / ) ) {
327+ prop = prop . toLowerCase ( ) ;
328+ }
316329
317330 // If prop is now "description", we need to rename it, because that's
318331 // reserved.
@@ -322,8 +335,8 @@ function asStructPropertyName(prop) {
322335
323336 // If prop starts with a sequence of capital letters (which can happen for
324337 // output of asLowerCamelCase if the original string started that way),
325- // lowercase all but the last one .
326- return prop . replace ( / ^ ( [ A - Z ] + ) ( [ A - Z ] ) / , ( match , p1 , p2 ) => {
338+ // followed by a lowercase letter, lowercase all but the last capital letter .
339+ return prop . replace ( / ^ ( [ A - Z ] + ) ( [ A - Z ] [ a - z ] ) / , ( match , p1 , p2 ) => {
327340 return p1 . toLowerCase ( ) + p2 ;
328341 } ) ;
329342}
0 commit comments