The Typescript 2.4 has introduced String Enums: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-4.html#string-enums
enum Colors {
Red = "RED",
Green = "GREEN",
Blue = "BLUE",
}
Unfortunately there is also a notice:
... string-initialized enums can’t be reverse-mapped to get the original enum member name. In other words, you can’t write
Colors["RED"]
to get the string "Red".
The swagger-codegen
generates the enums like this.
But how can we map properly from the string variable?