-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[typescript-node] fixed enum generator for top level enums #2266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
...va/org/openapitools/codegen/typescript/typescriptnode/TypescriptNodeEnumIntegrationTest.java
Outdated
Show resolved
Hide resolved
|
I have merged |
|
Dear TypeScript Technical Committee, can you have a look at this PR? @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @nicokoenig @topce |
| export enum {{classname}} { | ||
| {{#allowableValues}} | ||
| {{#enumVars}} | ||
| {{name}} = <any> {{{value}}}{{^-last}},{{/-last}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any particular reason for using <any> here?
it seems to work out without it e.g. here
openapi-generator/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache
Lines 6 to 12 in b797662
| export enum {{classname}} { | |
| {{#allowableValues}} | |
| {{#enumVars}} | |
| {{{name}}} = {{{value}}}{{^-last}},{{/-last}} | |
| {{/enumVars}} | |
| {{/allowableValues}} | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied this part from the already existing code for enums inside a request. "" was already used in the first typescript node template from Geoff Brown.
Being not a typescript expert myself I just didn't want to change too much.
And I just asked my typescript college, he thinks is not needed...
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class TypescriptNodeEnumIntegrationTest extends AbstractIntegrationTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this test do?
to simply compare the generated files it would be better to add a new variation to https://github.com/OpenAPITools/openapi-generator/blob/master/bin/typescript-node-petstore-all.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractIntegrationTest are generally disabled at the moment (disabled not by me, and I have not understood why).
To test my implementation, I temporarily activated integration test.
And I am hoping that integration tests will be active in the future.
The petstore example doesn't use enums.
And I agree an example with enums would be create.
|
@christof-vollrath-spring-media ping... I just came across this issue and was excited to see a fix... but it sounds like it still needs work? |
For us, everything looked fine with this fix. In the end we stopped using the Typescript client because of other issues concerning inheritance for incoming data. |
|
@christof-vollrath-spring-media thanks for your feedback. which issues concerning inheritance to you refer to? |
|
@christof-vollrath-spring-media thanks for the PR, which has been included in the 4.1.0 release: https://twitter.com/oas_generator/status/1160000504455319553 |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.sh,./bin/security/{LANG}-petstore.shand./bin/openapi3/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master,. Default:3.4.x,4.0.xmaster.Description of the PR
(details of the change, additional tests that have been done, reference to the issue for tracking, etc)