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.

[Feature] Support enumNames-like setting to generate enum with custom names

See original GitHub issue

There’s basically tow options.The first is use another field likeenumNames:string[] in OpenApiSchema to generate enums with custom names. Schema like this:

"state": {
    "title": "State",
    "enum": [
        0,
        1,
        2
    ],
    "type": "integer",
    "default": 0,
    "enumNames": ["initial", "working", "finished"]
}

Generated code:

enum state {
  INITIAL = 0,
  WORKING = 1,
  FINISHED = 2
}

But enumNames is not a valid openapi schema field. Another option is expanding the getEnumFromDescription.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ferdikoomencommented, Feb 16, 2020

I pushed some changes to the master branch, did not publish a new version yet. Feel free to have a look, i will do some final testing tomorrow.

0reactions
ferdikoomencommented, Feb 22, 2020

New version has been pushed (0.1.16) with support for enums

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Can my enums have friendly names? - Stack Overflow
public static string GetDescription(this Enum value) { Type type = value. ... You can use the Description attribute to get that friendly name....
Read more >
Attaching Values to Java Enum - Baeldung
Java provides a valueOf(String) method for all enum types. Thus, we can always get an enum value based on the declared name: assertSame(Element....
Read more >
Enum with Customized Value in Java - GeeksforGeeks
We have to create one getter method to get the value of enums. ... let's print name of each enum and there action....
Read more >
Integer enum with named items · Issue #681 - GitHub
[Feature] Support enumNames-like setting to generate enum with custom names ferdikoomen/openapi-typescript-codegen#96.
Read more >
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 >

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