[typescript] support for enum
See original GitHub issueDescription
Enum are not correctly generated in typescript client. Some investigation are requested to understand what is going wrong.
See also: https://www.typescriptlang.org/docs/handbook/enums.html
CC: @kayhuba
openapi-generator version
3.1.2
Command line used for generation
CLI to use the typescript-node
generator.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Handbook - Enums - TypeScript
Enums allow a developer to define a set of named constants. Using enums can make it easier to document intent, or create a...
Read more >Enum in TypeScript - TutorialsTeacher
Enums or enumerations are a new data type supported in TypeScript. Most object-oriented languages like Java and C# use enums. This is now...
Read more >How To Use Enums in TypeScript - DigitalOcean
In TypeScript, enums, or enumerated types, are data structures of constant length that hold a set of constant values. Each of these constant ......
Read more >TypeScript Enums - W3Schools
An enum is a special "class" that represents a group of constants (unchangeable variables). Enums come in two flavors string and numeric ....
Read more >TypeScript enums vs. types for writing readable code
Enums allow us to define or declare a collection of related values that can be numbers or strings as a set of named...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same problem here.
For typescript-node the generator does not correctly generate typescript enums if the enum is defined in OpenApi on the top level. In this case instead of generating an enum, a class is generated with the name of the enum and no attributes (see the example of jmini).
On the other side if it the enum is defined inside an object, everything works fine.
The bug seems to be in typescript-node/model.mustache. The template should make a difference between objects and enums, which it doesn’t.
The fix shouldn’t be to difficult, I am trying to fix it and making a pull request.
fixed with #2266 thanks @christof-vollrath-spring-media