fix(core): keep enum var names unique after renaming duplicates
postProcessEnumVars renames duplicate enum names by appending a counter, but new name can already be taken by another entry. Etc/GMT-1 becomes EtcGmt12 and Etc/GMT+12 already has that name after sanitizing, so full timezone enum gives TS1117 in typescript-* and duplicate constant ETC_GMT_122 in java
Now dedupe repeats while names are still not unqiue. Second pass runs only when duplicates are left, so output that was valid before is not changed
Added unit test in DefaultCodegenTest with names of Etc/GMT+12, Etc/GMT+1, Etc/GMT0, Etc/GMT-1 and Etc/GMT-12, it fails on master and passes with the fix. Generated typescript-angular and java enums from the full timezone list in #17277 have no duplicate names
Ran all configs with ./bin/generate-samples.sh ./bin/configs/*.yaml, no sample changes. ./mvnw clean package passes except Kotlin generator tests, those fail on JDK 25 on my machine (embedded Kotlin compiler)
On earlier attempt #22087 answer was enumPropertyNamingReplaceSpecialChar. That option is typescript only, so java and every other generator has no workaround except enumNameMappings or x-enum-varnames. This change doesn't rename anything that was valid, so it is not breaking and needs no option
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
Commit all changed files../mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Summary by cubic
Fixes enum variable name deduplication so renamed entries can no longer collide with existing names. postProcessEnumVars previously appended a counter on collision, but the new name could already be taken — e.g., Etc/GMT-1 becomes EtcGmt12, which collides with the sanitized name of Etc/GMT+12 — causing TS1117 errors in TypeScript generators and duplicate constants in Java. The pass now repeats until names are unique. Output that was already valid is unchanged, so this isn't breaking and needs no new option. Fixes #22074 and #17277.