I am using swagger-codegen-maven-plugin (2.2.1) to generate java and typescript code class files from YML configuration. I have two questions.
How to define array of enum property in YML?
How to define map property enum as key and boolean as value in YML?
Let me know is it possible or is there any workaround? Currently, I defined enum class in java and typescrtipt and pass it as string. Thanks.
DataInfo:
type: object
properties:
enumTest: -- works fine
type: string
enum:
- one
- two
enumTestArray: --failing to generate code
type: array
items:
type: string
enum:
- one
-two
testMap: -- works fines generate Map<String, Boolean> and { [key: string]: boolean; };
type: object
additionalProperties:
type: boolean
Updated:
Related to first question: Define array of enum property. swagger-codegen-maven-plugin generate invalid java class file as follows: Look like and issue with generating <, > and " characters.
@XmlType(name="List<EnumTestArrayEnum>")
@XmlEnum
public enum List<EnumTestArrayEnum> {
ONE(List<String>.valueOf(""one"")), TWO(List<String>.valueOf(""two""));
private List<String> value;
List<EnumTestArrayEnum> (List<String> v) {
value = v;
}
public String value() {
return value;
}
public static List<EnumTestArrayEnum> fromValue(String v) {
return valueOf(v);
}
}