question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[typescript] support for enum

See original GitHub issue
Description

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:closed
  • Created 5 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
christof-vollrath-spring-mediacommented, Feb 26, 2019

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.

0reactions
macjohnnycommented, Jul 15, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found