[typescript] Append enum suffix without model suffix#5138
[typescript] Append enum suffix without model suffix#5138macjohnny merged 11 commits intoOpenAPITools:masterfrom
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
There was a problem hiding this comment.
This is a mapping for the OAS2 built-in file type. It's similar to the existing mapping defined in TypeScriptAngularClientCodegen.java:
typeMapping.put("file", "Blob");
Without that, the updated toModelName() logic would add a bogus import for api endpoints that deal with type:file (imageUpload endpoint in PetStore)
Frankly, I'm not sure if the old mapping in line 151 here is needed at all.
|
@amakhrov Thanks a lot for your PR. |
|
@macjohnny i guess it depends on a point of view. However, one can argue that since generator still emits some valid typescript, it's not a bug but a feature. If you think it's rather a feature than a bugfix - do you think it's still valuable to be merged into the next major version? |
|
Thinking further about introducing backward incompatible changes.... Perhaps there is a way to keep compatibility by introducing a special |
|
@amakhrov I think it is a good idea to have a backwards-compatible behavior by default, so we can merge it and include it in the next patch release |
|
concerning bug or feature, since the code compiles as it is generated now, i would consider it a feature/improvement of the naming, which is, of course, favorable, too. |
|
All right, so I'll make the change described (introduce a special |
…ssed before running assertions
3f19d54 to
130c8ff
Compare
…r-enum-suffix # Conflicts: # docs/generators/javascript-flowtyped.md # docs/generators/typescript-angular.md # docs/generators/typescript-angularjs.md # docs/generators/typescript-aurelia.md # docs/generators/typescript-axios.md # docs/generators/typescript-fetch.md # docs/generators/typescript-inversify.md # docs/generators/typescript-jquery.md # docs/generators/typescript-node.md # docs/generators/typescript-redux-query.md # docs/generators/typescript-rxjs.md # modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java # modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java
|
Is it possible to not add a suffix to enums? |
Fixes #5135
I was not able to approach this problem without introducing backward-incompatible changes.A new
enumSuffixoption is introduced to minimize migration efforts, though.UPDATE: actually, backward compatibility is now ensured by having
v4-compatvalue by default for the newly introduced optionResponseModelPropNameModelEnumwe now getResponseModelPropNameEnum.ResponsePropNameEnum)modelSuffix, though - so it's still possible to configure it viamodelNameSuffixormodelSuffix. Both options should work the same with the updated enum naming schema.enumSuffixis 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).error(note lowcase!), which would then emit a Typescript interfaceError. This should not have been possible, becauseErroris 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 [BUG][typescript] Models named after language-specific types generate incorrectly #5139)PR checklist
./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.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @nicokoenig @topce @akehir @petejohansonxo