如何为swagger-UI文档的每个枚举值添加一些描述?
我的EnumClass:
@ApiModel
public enum EnumCarrierSelectionSubstitutionInformation {
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_1(1), //
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_2(2), //
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_3(3), //
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_4(4), //
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_5(5), //
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_6(6), //
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_7(7);
private int numVal;
EnumCarrierSelectionSubstitutionInformation(int numVal) {
this.numVal = numVal;
}
public int getNumVal() {
return numVal;
}
}
模型
private EnumCarrierSelectionSubstitutionInformation carrierSelectionSubstitutionInformation;
// getter setter......
我想在CARRIER_SELECTION_SUBSTITUTION_INFORMATION_1
添加一些说明。
我试过
@ApiModelProperty(value = "blabla2")
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_1(1), //
但这不起作用。
Swagger-UI输出:
carrierSelectionSubstitutionInformation (string, optional) = ['CARRIER_SELECTION_SUBSTITUTION_INFORMATION_1', 'CARRIER_SELECTION_SUBSTITUTION_INFORMATION_2', 'CARRIER_SELECTION_SUBSTITUTION_INFORMATION_3', 'CARRIER_SELECTION_SUBSTITUTION_INFORMATION_4', 'CARRIER_SELECTION_SUBSTITUTION_INFORMATION_5', 'CARRIER_SELECTION_SUBSTITUTION_INFORMATION_6', 'CARRIER_SELECTION_SUBSTITUTION_INFORMATION_7']
string
Enum: "CARRIER_SELECTION_SUBSTITUTION_INFORMATION_1", "CARRIER_SELECTION_SUBSTITUTION_INFORMATION_2", "CARRIER_SELECTION_SUBSTITUTION_INFORMATION_3", "CARRIER_SELECTION_SUBSTITUTION_INFORMATION_4", "CARRIER_SELECTION_SUBSTITUTION_INFORMATION_5", "CARRIER_SELECTION_SUBSTITUTION_INFORMATION_6", "CARRIER_SELECTION_SUBSTITUTION_INFORMATION_7"
我该怎么做?
答案 0 :(得分:0)
public class Enum {
public enum EnumCarrierSelectionSubstitutionInformation {
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_1(1,"ONE"), //
CARRIER_SELECTION_SUBSTITUTION_INFORMATION_2(2,"TWO"),
private final int value;
private final String description;
EnumCarrierSelectionSubstitutionInformation(int value, String desc){
this.value = value;
this.description = desc;
}
public int value(){
return this.value;
}
public String description(){
return this.description;
}
}
public static void main(String[] args){
for (EnumCarrierSelectionSubstitutionInformation elem: EnumCarrierSelectionSubstitutionInformation.values()){
System.out.println(elem + "value is "+ new Integer(elem.value()) + " desc is " + elem.description());
}
}
}