We use microprofile openapi annotations to generate Swagger documentation for our rest interfaces. Enums often have a property that stores the "display name", which is shown instead of the Enum.
For example:
@AllArgsConstructor
@Getter
@JsonbTypeAdapter(MyEnumAdapter.class)
@Schema(implementation = MyEnum.class)
public enum MyEnum{
V1("displayname v1"),
V2("displayname v2"),
V3("displayname v3");
private final String name;
@Nullable
public static MyEnumfromString(String name) {
return Arrays.stream(values()).filter(u -> u.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
}
}
Swagger shows enum like this:
MyEnum string
Enum:
[ V1, V2, V3 ]
What I want:
MyEnum string
Enum:
[ "displayname V1", "displayname V2", "displayname V3" ]
The APIs return the "display name", however, Swagger shows the "Enum name" which often leads to confusion. Is there a possibility to change the Swagger values?