-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[BUG] Go generator: no way to generate enums of integers with a named variable #21203
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
Comments
I found a way to make it work, but this is still a bug. Using x-enum-varnames DOES work, but specifically ONLY if using a separate component It does not work to have a structured component with an item inside that is of type: enum For example one needs to do (WORKS):
...
It does NOT work to inline it as follows:
The code generation will silently skip generating the const for the values in x-enum-varnames. |
You can configure the generator to resolve these inline enums without moving them to a $ref'ed schema by running the generator with {
<your existing config>,
"inlineSchemaOptions": {
"RESOLVE_INLINE_ENUMS": true
}
} There are other customizations as well that can be useful to change how your code is generated based on the input spec: https://openapi-generator.tech/docs/customization/#inline-schema-naming Also, a heads up that you may want to run the generator with |
oh I see, it's an optional feature. I didn't know that the --inline-schema-options existed, works as intended then. Thanks! |
There is currently no way to have the go code generator create a variable of integer type, with named const definitions for it.
I tried x-enum-varnames, x-enum-names,
oneOf: with title: ,
nothing at all seems to be supported for the Go generator.
This is pretty bad as I will need to open code each single variable for each enum.
Only enums with type: string currently work with the Go generator, which is too wasteful of space for my project, will need to use another generator.
The text was updated successfully, but these errors were encountered: