fix(typescript-angular): resolve model imports with lowercase modelSuffix
toModelName appends modelSuffix with _ and camelizes result, so modelSuffix=dto gives PetDto class, same as Dto
removeModelPrefixSuffix compares class name with raw dto, nothing gets stripped and suffix is added once more when file name is built
So with dto model file is petDto.ts, while imports in models and services point to petDtoDto, generated client fails with TS2307 as soon as one model references another or service uses model
Same for any suffix that starts with lowercase letter, example from issue gives ./municipalityRestDtoExampleExample
Now removeModelPrefixSuffix strips capitalize(modelSuffix), it alredy does same for modelNamePrefix and modelNameSuffix few lines below
Suffix validation allows only letters and digits, so capitalized suffix is exactly what camelize puts into class name
With lowercase suffix model files now get same names as with capitalized one (pet.ts for PetDto), barrel models.ts follows them
Only handwritten deep import like model/petDto would notice rename, and before this such client compiled only when no model referenced another and no service used model
Added testModelImportsWithLowercaseModelSuffix, it generates petstore with Dto and dto and checks file name and imports in model and service, dto case fails on master
Sample configs use only modelSuffix: Model, regenerated typescript-angular samples have no diff
Fixes #20726
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,
@mentionthe technical committee members, so they are more likely to review the pull request.
Summary by cubic
Fixes broken model imports in typescript-angular when modelSuffix starts with a lowercase letter (e.g. dto).
The generator camelizes the suffix when building class names, so dto becomes Dto. removeModelPrefixSuffix still compared against the raw dto, leaving the suffix in place, which made imports point to files like petDtoDto.ts while the actual file was petDto.ts — failing with TS2307.
- Strips
capitalize(modelSuffix)so model file names match the class names produced bytoModelName. - Adds a test that generates the petstore with both
Dtoanddtosuffixes and verifies file names and imports in models and services.