[typescript-angular] Fix multiple imports from same module in importMappings and duplicate model re-exports

SL
2h ago
+269-6

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (Samples are unaffected as existing samples do not use multiple importMappings from 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:

  1. Service Import Map Collision (TypeScriptAngularClientCodegen.java):
    When multiple schemas mapped to the same module/package (e.g. @contracts or @foo/bar) via importMappings, 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 postProcessOperationsWithModels from the operations' imports so all imported symbols are preserved without collision.
  2. Duplicate Re-Exports in models.ts (TypeScriptAngularClientCodegen.java & models.mustache):
    In models.ts, models mapped to external packages via importMappings were repeatedly re-exported via export * 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 postProcessSupportingFileData and deduplicated per module so export * from '<module>'; is emitted only once per external module in models.ts.
  3. Automated Tests:
    Added unit tests in TypeScriptAngularClientCodegenTest.java (testMultipleImportsFromSameModuleAndExternalModelReExport and testIssue22533ImportMappingsSamePathInServices) verifying that all external symbols from the same module are imported in services and re-exported without duplicates in models.ts.

Fixes #22533
Supersedes #23758
Relates to #7790