DEV Community

Discussion on: Enums & APIs

Collapse
 
mweel1 profile image
Mardo

I believe enums work great in a single service boundary.

However, once you start exposing them in API's what is the consumer to do with an integer?

It most likely will end up in a database where they have no reference to what the enum is, where a string is always self-documented. They could create a cross-reference and map it to their own enums, but that is just another place something can break or get crossed up.

I'm sticking with strings where I am exposing outside of my service boundary because they are self-documented, and not up for interpretation.