OpenAPITools / OpenAPITools/openapi-generator
[BUG] OpenAPI 3.x Go generation's weirdness for enum names
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Currently, the enum names will be stripped the common prefixes.
If
- FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY
- FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY
Then the enum names are:
const (
INTERNAL_CHANNEL_EMPTY WorkflowConditionalCloseType = "FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY"
SIGNAL_CHANNEL_EMPTY WorkflowConditionalCloseType = "FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY"
)
However, if
- FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY
- FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY
- GRACEFUL_COMPLETE_ON_ALL_CHANNELS_EMPTY
Then the enum names are
const (
FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY WorkflowConditionalCloseType = "FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY"
FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY WorkflowConditionalCloseType = "FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY"
GRACEFUL_COMPLETE_ON_ALL_CHANNELS_EMPTY WorkflowConditionalCloseType = "GRACEFUL_COMPLETE_ON_ALL_CHANNELS_EMPTY"
)
Because they don't have the shared common prefix anymore. The generator is "trying to be smart" but it's a terrible idea to do this without any parameter to control.
This would be a problem because the enum names are unstable as adding different values.
It will be nice to somehow get rid of this "smart stripping"...
A workaround today is to use "enumClassPrefix=true" however, this is also a breaking change to all enum names, and also the enum names will be quite ugly like this...:
const (
WORKFLOWCONDITIONALCLOSETYPE_FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY WorkflowConditionalCloseType = "FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY"
WORKFLOWCONDITIONALCLOSETYPE_FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY WorkflowConditionalCloseType = "FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY"
WORKFLOWCONDITIONALCLOSETYPE_GRACEFUL_COMPLETE_ON_ALL_CHANNELS_EMPTY WorkflowConditionalCloseType = "GRACEFUL_COMPLETE_ON_ALL_CHANNELS_EMPTY"
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Go enum-name generation logic in the OpenAPI generator and reproduce the behavior with the enum values shown in the issue. Determine how shared-prefix stripping is applied, then verify that adding an enum value does not rename existing constants and that the generated Go output remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100