[Dart] Preserve uppercase names with trailing digits

Merged
SJ
5mo ago
+5-1

Summary

Closes #23786.

Updates Dart variable and enum name normalization so all-uppercase names with trailing digits, such as FOO2 and FOO_BAR2, are treated like the existing FOO and FOO_BAR cases instead of being camelized.

Details

  • Allows digits in the all-uppercase preservation path when the normalized name starts with an uppercase letter or underscore.
  • Adds regression coverage for FOO2 and FOO_BAR2.
  • Keeps existing leading-digit behavior such as _5FOO -> n5fOO.

Testing

  • ./mvnw -pl modules/openapi-generator -am -Dtest=org.openapitools.codegen.dart.DartModelTest#convertVarName+convertEnumVarNames -Dsurefire.failIfNoSpecifiedTests=false test
  • git diff --check

Summary by cubic

Preserves all-uppercase Dart variable and enum names with trailing digits (e.g., FOO2, FOO_BAR2) so they are not camelized, matching existing all-uppercase handling.

  • Bug Fixes
    • Updated normalization to allow digits after an initial uppercase or underscore (^[A-Z_][A-Z0-9_]*$).
    • Added regression tests for FOO2 and FOO_BAR2.
    • Kept leading-digit normalization (e.g., _5FOO -> n5fOO) unchanged.