[typescript-angular] Fix multiple imports from same module in importMappings and duplicate model re-exports
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(Samples are unaffected as existing samples do not use multiple./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exitimportMappingsfrom the same module). - If your PR is targeting a particular programming language, @mention the technical committee members: @macjohnny @topce @akehir
Description of the change
This PR addresses two related issues when using importMappings with the TypeScript Angular generator:
-
Service Import Map Collision (
TypeScriptAngularClientCodegen.java):
When multiple schemas mapped to the same module/package (e.g.@contractsor@foo/bar) viaimportMappings, imports were previously reduced by target module key, resulting in only one class being imported into generated API service files.- Fix: Recomputed model imports in
postProcessOperationsWithModelsfrom the operations' imports so all imported symbols are preserved without collision.
- Fix: Recomputed model imports in
-
Duplicate Re-Exports in
models.ts(TypeScriptAngularClientCodegen.java&models.mustache):
Inmodels.ts, models mapped to external packages viaimportMappingswere repeatedly re-exported viaexport * from '<module>';for every mapped model (causing duplicate export statements when multiple models shared the same import path).- Fix: External mapped models are now recognized in
postProcessSupportingFileDataand deduplicated per module soexport * from '<module>';is emitted only once per external module inmodels.ts.
- Fix: External mapped models are now recognized in
-
Automated Tests:
Added unit tests inTypeScriptAngularClientCodegenTest.java(testMultipleImportsFromSameModuleAndExternalModelReExportandtestIssue22533ImportMappingsSamePathInServices) verifying that all external symbols from the same module are imported in services and re-exported without duplicates inmodels.ts.