[Feature] Support enumNames-like setting to generate enum with custom names
See original GitHub issueThere’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:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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.
New version has been pushed (0.1.16) with support for enums