fix(go): avoid duplicate unknown enum defaults#23909
Merged
wing328 merged 2 commits intoJun 1, 2026
Merged
Conversation
wing328
reviewed
Jun 1, 2026
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| private void prefixEnumUnknownDefaultCase(CodegenModel model) { |
Member
There was a problem hiding this comment.
please add a docstring explaining what this function does
a few inline comments explaining the if blocks below would be helpful too
Contributor
Author
There was a problem hiding this comment.
Added Javadoc for prefixEnumUnknownDefaultCase and inline comments for the guard conditions and fallback-name update.
Member
|
tested locally and the result is good (no compilation error) --- a/model_status_a.go
+++ b/model_status_a.go
@@ -22,7 +22,7 @@ type StatusA string
const (
ACTIVE StatusA = "active"
INACTIVE StatusA = "inactive"
- UNKNOWN_DEFAULT_OPEN_API StatusA = "unknown_default_open_api"
+ STATUSA_UNKNOWN_DEFAULT_OPEN_API StatusA = "unknown_default_open_api"
)
// All allowed values of StatusA enum
@@ -46,7 +46,7 @@ func (v *StatusA) UnmarshalJSON(src []byte) error {
}
}
- *v = UNKNOWN_DEFAULT_OPEN_API
+ *v = STATUSA_UNKNOWN_DEFAULT_OPEN_API
return nil
}
will merge once all the tests pass |
Member
Member
|
Thanks for the PR which has been merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #23844.
What
unknown_default_open_apienum fallback whenenumClassPrefix=false.Testing
./mvnw -pl modules/openapi-generator -am -Dtest=org.openapitools.codegen.go.GoClientCodegenTest#testEnumUnknownDefaultCaseUsesModelSpecificNamesWhenEnumClassPrefixDisabled -Dsurefire.failIfNoSpecifiedTests=false test./mvnw -pl modules/openapi-generator -am -Dtest=org.openapitools.codegen.go.GoClientCodegenTest -Dsurefire.failIfNoSpecifiedTests=false testgit diff --checkSummary by cubic
Avoids duplicate Go enum fallback constants by prefixing the synthetic unknown default with the model name when
enumClassPrefix=false. Fixes #23844.unknown_default_open_apifallback with the model name whenenumUnknownDefaultCase=trueandenumClassPrefix=false, preventing collisions across models in the same package.Written for commit e230699. Summary will update on new commits.