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
For the following enum example, which implements an interface, which declares a @JsonValue method, the method is not used when creating the OpenAPI schema:
Interface:
public interface ValueAndLabel<T extends Serializable> {
@JsonValue
T getValue();
String getLabel();
}
Enum:
public enum ExampleEnum implements ValueAndLabel<Integer> {
_1_ONE(1, "One"),
_2_TWO(2, "Two"),
_3_THREE(3, "Three"),
;
private final Integer value;
private final String label;
ExampleEnum(final Integer value, final String label) {
this.value = value;
this.label = label;
}
public Integer getValue() {
return value;
}
public String getLabel() {
return label;
}
}
The problem is, that it is nescessary to add the annotation on every single implementation of the enum, for the schema to be correct. Jackson serializer is using the annotation of the interface, so the application is working perfectly fine without the annotation, but the schema is wrong.
The text was updated successfully, but these errors were encountered:
For the following enum example, which implements an interface, which declares a @JsonValue method, the method is not used when creating the OpenAPI schema:
Interface:
Enum:
Produces:
When adding the @JsonValue annotation to the implementation of the enum it works as expected:
Enum:
Produces:
The problem is, that it is nescessary to add the annotation on every single implementation of the enum, for the schema to be correct. Jackson serializer is using the annotation of the interface, so the application is working perfectly fine without the annotation, but the schema is wrong.
The text was updated successfully, but these errors were encountered: