-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
[Feature] Support enumNames-like setting to generate enum with custom names #96
Comments
there is a nice thread here OAI/OpenAPI-Specification#681 some client support the x-enum-varnames. The x- props are extension props in the V3 spec. That might be a semi-supported way to do it. |
The code is not hard, I will have a look soon! |
@songzhi would the following SPEC work for you? Example with x-enum-varnames and x-enum-descriptions {
"EnumWithStrings": {
"description": "This is a simple enum with strings",
"enum": [
0,
1,
2
],
"x-enum-varnames": [
"Success",
"Warning"
"Error"
],
"x-enum-descriptions": [
"Used when the status of something is successful",
"Used when the status of something has a warning"
"Used when the status of something has an error"
]
}
} |
@ferdikoomen It's works for me. Thanks for this. |
Alright, i will try to implement this in the upcoming days. Keep you posted |
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 |
fix(config): set lint to false by default
There's basically tow options.The first is use another field like
enumNames:string[]
inOpenApiSchema
to generate enums with custom names.Schema like this:
Generated code:
But enumNames is not a valid openapi schema field.
Another option is expanding the
getEnumFromDescription
.The text was updated successfully, but these errors were encountered: