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
If set enumUnknowDefaultCase to true then additional enum (UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");) is generated properly but fromValue function end with throw new IllegalArgumentException("Unexpected value '" + value + "'"); but should end with return UNKNOWN_DEFAULT_OPEN_API;
openapi-generator 5.4.0
Suggest a fix
in modelEnum.mustache replace:
public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (b.value.equals(value)) {
return b;
}
}
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}}
}
with
public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (b.value.equals(value)) {
return b;
}
}
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}}
}
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
If set enumUnknowDefaultCase to true then additional enum (
UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");
) is generated properly butfromValue
function end withthrow new IllegalArgumentException("Unexpected value '" + value + "'");
but should end withreturn UNKNOWN_DEFAULT_OPEN_API;
openapi-generator 5.4.0
Suggest a fix
in modelEnum.mustache replace:
with
The text was updated successfully, but these errors were encountered: