I am using Swagger-UI with Java spring/hibernate. The Swagger UI version is 2.
I am having hard time in using enums.
I have a POJO model in which I have following enum property declared.
@Enumerated(EnumType.STRING)
@Column(name = "gender")
@Access(AccessType.FIELD)
private Gender gender;
and the Gender is enum as follows:
public enum Gender {
M("Male"), F("Female");
private String displayValue;
private Gender(String displayValue) {
this.displayValue = displayValue;
}
@Override
public String toString() {
return displayValue;
}
public String getDisplayValue() {
return displayValue;
}
public String getName() {
return name();
}
}
But my swagger displays only display values (male
or female
) in UI as well as the dropdown's display value. I want Swagger UI to display something similar like below which is HTML equivalent:
<select name="gender">
<option value="M">Male</option>
<option value="F">Female</option>
</select>
How to achieve this? Reading up the Swagger UI docs, its so much confusing for me, unable to understand it. please help.