You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The current golang server enum template modules/openapi-generator/src/main/resources/go-server/model.mustache produces a bugged code for enum values.
The New{{{classname}}}FromValue function always returns an empty string when the ev is not valid, so for integer enums the code does not compile.
The bugged code is the following
funcNewErrorCodesFromValue(vint32) (ErrorCodes, error) {
ev:=ErrorCodes(v)
ifev.IsValid() {
returnev, nil
}
return"", fmt.Errorf("invalid value '%v' for ErrorCodes: valid values are %v", v, AllowedErrorCodesEnumValues)
}
Expected output
funcNewErrorCodesFromValue(vint32) (ErrorCodes, error) {
ev:=ErrorCodes(v)
ifev.IsValid() {
returnev, nil
}
noValue:=new(ErrorCodes)
return*noValue, fmt.Errorf("invalid value '%v' for ErrorCodes: valid values are %v", v, AllowedErrorCodesEnumValues)
}
openapi-generator version
The latest version is affected
OpenAPI declaration file content or url
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
The current golang server enum template
modules/openapi-generator/src/main/resources/go-server/model.mustache
produces a bugged code for enum values.The
New{{{classname}}}FromValue
function always returns an empty string when theev
is not valid, so for integer enums the code does not compile.The bugged code is the following
Expected output
openapi-generator version
The latest version is affected
OpenAPI declaration file content or url
The text was updated successfully, but these errors were encountered: