-
Notifications
You must be signed in to change notification settings - Fork 6k
Open
Description
Reopen of ticket #10546 as the provided fix does not solve the issue. The generated Java code still looks as follows:
/**
* True or False indicator
*/
@JsonAdapter(ModelBoolean.Adapter.class)
public enum ModelBoolean {
TRUE("true"),
FALSE("false");
private Boolean value;
ModelBoolean(Boolean value) {
this.value = value;
}
public Boolean getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static ModelBoolean fromValue(String text) {
for (ModelBoolean b : ModelBoolean.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
public static class Adapter extends TypeAdapter<ModelBoolean> {
@Override
public void write(final JsonWriter jsonWriter, final ModelBoolean enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public ModelBoolean read(final JsonReader jsonReader) throws IOException {
Boolean value = jsonReader.nextBoolean();
return ModelBoolean.fromValue(String.valueOf(value));
}
}
}This is not a valid Java code. The constructor requires a value of type Boolean ModelBoolean(Boolean value), but is called with values of type String TRUE("true").
Tested with Swagegr Codegen Version 2.4.18 and version 3.0.24. Both sould include the fix.
Metadata
Metadata
Assignees
Labels
No labels