Looked at issue #3611 #3615
It does not work for language jaxrs .
I tried using 2.2.3 and 2.3.0 lastest snapshot also.
java -jar swagger-codegen-cli-2.3.0.jar generate -i genapi.yaml -l jaxrs -o generated_server
public enum HealthType {
OVERALL("overall"),
CONNECTED("connected"),
ONBOARDED("onboarded");
private String value;
HealthType(String value) {
this.value = value;
}
@override
public String toString() {
return String.valueOf(value);
}
@jsoncreator
public static HealthType fromValue(String text) {
for (HealthType b : HealthType.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
}
See the same issue..Any responses?
Do not put a @JsonValue at the toString() method. Add a new method:
@JsonValue
public {{dataType}} getValue() {
return value;
}
This will work for non-String enums, too.
Imaging enums of datatype Integer or Double.
This is a generated file.
Cannot add code here.
It should be fixed from the swagger codegen
@sdoeringNew please check this
Yeah, sure. I already fixed a similar issue for the Java code generation.
I just mean: It would be wrong to fix this issue by adding a @JsonValue at the toString() method.
I think it's better to use Jackson's WRITE_ENUMS_USING_TO_STRING property
@cbornet : You mean while deserializing? Could you give me an example?
Most helpful comment
See the same issue..Any responses?