I have a class that looks like this:
public class Rule {
private RuleType type; //enum
private String value;
}
The enum is:
public enum RuleType {
TYPE_A, TYPE_B, TYPE_C;
}
Now each rule type the values are different. TYPE_A requires a number 1 through 10, TYPE_B is true or false, and TYPE_C is a string. I am trying to add swagger annotations to the enum so that the documentation can show this, something like this:
public enum RuleType {
@ApiModelProperty(value = "1 - 10")
TYPE_A,
@ApiModelProperty(value = "True or False")
TYPE_B,
@ApiModelProperty(value = "String")
TYPE_C;
}
But this doesn't work. The swagger produced just ignores the properties on the enums. Is there a way to create documentation like this?
TYPE_A
, it would always beTYPE_A
itself right? If it can have multiple values, it should be of a different data type and not an enum. For eg, ifTYPE_B
can be true or false, you should be using a boolean instead right? I believe you need to change your class design. – SigurdRuleType
. – Coheir