Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !5138

[typescript] Append enum suffix without model suffix

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/crunchbase/typescript-angular-enum-suffix into master Jan 29, 2020
  • Overview 0
  • Commits 11
  • Pipelines 0
  • Changes 20

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 enumSuffix option is introduced to minimize migration efforts, though. UPDATE: actually, backward compatibility is now ensured by having 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 get ResponseModelPropNameEnum.
  • 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 via modelNameSuffix or modelSuffix. 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 interface Error. This should not have been possible, because Error 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

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/crunchbase/typescript-angular-enum-suffix