Skip to content
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

[BUG] OpenAPI 3.x Go generation's weirdness for enum names #16002

Open
longquanzheng opened this issue Jul 4, 2023 · 0 comments
Open

[BUG] OpenAPI 3.x Go generation's weirdness for enum names #16002

longquanzheng opened this issue Jul 4, 2023 · 0 comments

Comments

@longquanzheng
Copy link

longquanzheng commented Jul 4, 2023

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"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant