Created by: amakhrov
Fixes https://github.com/OpenAPITools/openapi-generator/issues/5135
I was not able to approach this problem without introducing backward-incompatible changes.
A new
UPDATE: actually, backward compatibility is now ensured by having enumSuffix
option is introduced to minimize migration efforts, though.v4-compat
value by default for the newly introduced option
- (breaking change) With modelNameSuffix, only append "Enum" suffix but not model suffix. So instead of
ResponseModelPropNameModelEnum
we now getResponseModelPropNameEnum
. - Without modelNameSuffix, all typescript generators except typescript-angular keep the existing behavior (emit smth like
ResponsePropNameEnum
) - (breaking change) typescript-angular now follows the same enum naming rules as other TS generators. It still uses its custom
modelSuffix
, though - so it's still possible to configure it viamodelNameSuffix
ormodelSuffix
. Both options should work the same with the updated enum naming schema. -
enumSuffix
is now configurable via options. This would provide smoother migration for existing users (e.g. one can set it to "ModelEnum" to mimic the old behavior). - (bonus) More robust model names generation. Previously it would be possible to have a spec with a model named
error
(note lowcase!), which would then emit a Typescript interfaceError
. This should not have been possible, becauseError
is a builtin class. Now all the sanity checks are done to a fully-transformed model (after being camelized, and adding prefix and suffix). This addresses a part of the problem described in https://github.com/OpenAPITools/openapi-generator/issues/5139)
PR checklist
-
Read the contribution guidelines. -
Run the shell script(s) under ./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc). -
File the PR against the correct branch: master
,4.3.x
,5.0.x
. Default:master
. -
Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @nicokoenig @topce @akehir @petejohansonxo