Skip to content

Preserve enum values with colliding Go names - #2678

Merged
mromaszewicz merged 2 commits into
oapi-codegen:mainfrom
wozhenbang2004:fix-enum-go-name-collisions
Nov 21, 2026
Merged

mromaszewicz merged 2 commits into
oapi-codegen:mainfrom
wozhenbang2004:fix-enum-go-name-collisions

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Fixes #2674.

Allocate unique names after the final schema-name conversion, and reserve existing suffixes when naming server URL variables. This preserves the declared enum values and keeps the default tied to the correct value.

Verified both paths with the generated Go. make tidy, make test, make generate, and make lint passed.

@wozhenbang2004
wozhenbang2004 requested a review from a team as a code owner November 20, 2026 23:43
@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR preserves enum values when different names become the same Go name.

  • Schema enums keep distinct values under unique generated constant names.
  • Server URL enum values get unique names without taking another value's suffix.

Reviews (2) · Last reviewed commit: "test: cover old-enum-conflicts enum name..." · Reviewed by Greptile

@mromaszewicz mromaszewicz added the bug Something isn't working label Nov 21, 2026
Exercise the `compatibility.old-enum-conflicts` branch of the enum
naming fix: names that collide after the path-prefixed conversion each
keep a constant, and a numeric suffix skips a name owned by a later
value.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mromaszewicz
mromaszewicz merged commit c4e7f51 into oapi-codegen:main Nov 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum values are silently dropped when their constant names collide (schema enums and server URL variables)

2 participants