OpenAPI 3.x Go generation's weirdness for enum names
- Dominant language
- Go
- Stars
- 661
- Forks
- 63
- PR merge metrics
- No merged PRs in 30d
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:
```
INTERNAL_CHANNEL_EMPTY
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
```
FORCE_COMPLETE_ON_INTERNAL_CHANNEL_EMPTY
FORCE_COMPLETE_ON_SIGNAL_CHANNEL_EMPTY
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...
Reported in https://github.com/OpenAPITools/openapi-generator/issues/16002
As a workaround today, make sure to have at least a letter different in all the enums from beginning...
Contributor guide
Research direction
The issue names no repository files or tests. Start by locating the OpenAPI 3.x Go-generation configuration and the schema containing the enum examples, then compare generated names with and without the third value. Done means enum names remain stable without requiring enumClassPrefix=true, with tests covering both value sets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100