You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
x-enum-varnames removes any underscores in the provided enum names #1906
Thanks for the report!
To help maintainers (or other users) help with triaging and fixing of the issue more easily, we need a Minimal Reproduction test case.
Please follow the instructions, and then share a URL to the repository.
We will not accept .zip files as reproductions, sorry!
As of #2683 there is an opt-in setting that emits the names in x-enum-varnames (and x-enumNames) exactly as you wrote them, instead of running them through the name normalizer.
With verbatim, each name has to be a valid Go identifier, and it is used as is: it is not capitalized, not renamed if it collides with another name, and not prefixed with the type name. The setting also applies to x-go-name on properties and parameters.
If you only want the underscores kept, and still want the names normalized otherwise, output-options.naming.enum-values.keep-underscores: true does that, for enum values as well as for x-enum-varnames.
The option is opt-in, so nothing changes unless you set it. It will be released in v2.9.0. Until then you need to use the main branch, for example:
go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@main --config=config.yaml spec.yaml
Activity
github-actions commentedon Apr 21, 2025
Thanks for the report!
To help maintainers (or other users) help with triaging and fixing of the issue more easily, we need a Minimal Reproduction test case.
Please follow the instructions, and then share a URL to the repository.
We will not accept
.zipfiles as reproductions, sorry!mromaszewicz commentedon Nov 21, 2026
As of #2683 there is an opt-in setting that emits the names in
x-enum-varnames(andx-enumNames) exactly as you wrote them, instead of running them through the name normalizer.Add this to your configuration:
For example, with this schema:
the generated code is now:
With
verbatim, each name has to be a valid Go identifier, and it is used as is: it is not capitalized, not renamed if it collides with another name, and not prefixed with the type name. The setting also applies tox-go-nameon properties and parameters.If you only want the underscores kept, and still want the names normalized otherwise,
output-options.naming.enum-values.keep-underscores: truedoes that, for enum values as well as forx-enum-varnames.The option is opt-in, so nothing changes unless you set it. It will be released in v2.9.0. Until then you need to use the
mainbranch, for example:The other naming options are described in the README under Adjusting how names are normalized.