I am getting the following error when trying to get the enum values for an allowableValues tag.
The value for annotation attribute ApiModelProperty.allowableValues must be a constant expression
What I am trying to do:
@ApiModelProperty(allowableValues = new Enums().enumToString(SomeEnum.class))
private String someString;
Here is the logic for Enums().enumToString
public class Enums {
public final <E extends Enum<E>> String enumToString(Class<E> inputEnum) {
//inputEnum;
for (Enum enumValues : EnumSet.allOf(inputEnum)) {
//will create a string of the enum values
}
return "will be a formatted string of the enum values";
}
}
Is it possible to do what I am trying to accomplish? I know it is possible to just expose the enum in my API and swagger would then recognize the allowed values automatically, however the field in question needs to be exposed as a string, even though our internal logic has it as an enum.
Thanks in advance for your help!