Skip to content

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

Description

@longquanzheng

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"
)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions