Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
toModelNameappendsmodelSuffixwith_and camelizes result, somodelSuffix=dtogivesPetDtoclass, same asDtoremoveModelPrefixSuffixcompares class name with rawdto, nothing gets stripped and suffix is added once more when file name is builtSo with
dtomodel file ispetDto.ts, while imports in models and services point topetDtoDto, generated client fails with TS2307 as soon as one model references another or service uses modelSame for any suffix that starts with lowercase letter,
examplefrom issue gives./municipalityRestDtoExampleExampleNow
removeModelPrefixSuffixstripscapitalize(modelSuffix), it alredy does same formodelNamePrefixandmodelNameSuffixfew lines belowSuffix 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.tsforPetDto), barrelmodels.tsfollows themOnly handwritten deep import like
model/petDtowould notice rename, and before this such client compiled only when no model referenced another and no service used modelAdded
testModelImportsWithLowercaseModelSuffix, it generates petstore withDtoanddtoand checks file name and imports in model and service,dtocase fails on masterSample configs use only
modelSuffix: Model, regenerated typescript-angular samples have no diffFixes #20726
PR checklist
@mentionthe technical committee members, so they are more likely to review the pull request.Summary by cubic
Fixes broken model imports in
typescript-angularwhenmodelSuffixstarts with a lowercase letter (e.g.dto).The generator camelizes the suffix when building class names, so
dtobecomesDto.removeModelPrefixSuffixstill compared against the rawdto, leaving the suffix in place, which made imports point to files likepetDtoDto.tswhile the actual file waspetDto.ts— failing with TS2307.capitalize(modelSuffix)so model file names match the class names produced bytoModelName.Dtoanddtosuffixes and verifies file names and imports in models and services.Written for commit 1cb9446. Summary will update on new commits.