gpt4 book ai didi

java - 为 swagger-UI 文档的每个枚举值添加描述

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:18 25 4
gpt4 key购买 nike

如何为 swagger-UI 文档的每个枚举值添加一些描述?

我的枚举类:

@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"

我该怎么做?

最佳答案

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());
}
}
}

关于java - 为 swagger-UI 文档的每个枚举值添加描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49531506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com