Assuming this enum(AAA = 'aaa', CCC = 'ccc'). Today the client send the server the string value=aaa and the server validates it against the optional values. I can create a server side map that will create a new enum(AAA = 1, CCC = 2) and when I get value=1 I'll know the client actually means aaa.
However, our server grows rapidly and new enum values may be added in the future, e.g. BBB. How can I make sure that all generated client will match all compatible versions of the servers on different environments if the map is generated dynamically based on the existing values. Note that the order of the values is also not always the same because on different environments I may install different plugins that may cause different values sets in the enums. Of course that mapping the enums on the client side will only increase the issue. So I was wondering if there is a way to implement string enums using constants that instantiated with string value for example. T. -----Original Message----- From: Jens Geyer [mailto:[email protected]] Sent: Sunday, April 19, 2015 7:14 PM To: [email protected] Subject: Re: String enums Ok, now I'm pretty sure I don't understand the problem. Why do you have to change the API when you only want to map enums to strings in the client? -----Ursprüngliche Nachricht----- From: Jonathan Kanarek Sent: Sunday, April 19, 2015 5:46 PM To: [email protected] Subject: RE: String enums I want to keep the server side as is and implement only client libraries. If no one have a better idea, I guess I'll have to implement changes on the server side as well. T. -----Original Message----- From: Jens Geyer [mailto:[email protected]] Sent: Sunday, April 19, 2015 6:22 PM To: [email protected] Subject: Re: String enums > How would you implement it without generating translation map? That was my first thought, to be honest. What speaks against it? Or maybe I just don't understand the problem right. -----Ursprüngliche Nachricht----- From: Jonathan Kanarek Sent: Sunday, April 19, 2015 4:57 PM To: [email protected] Subject: String enums Hi, I want to expose existing server which currently supports enums that their values are strings. How would you implement it without generating translation map? T.
