Generated Enums Break When APIs Add New Values
Generated enums are closed sets by default, so when a server adds a value the client has not seen, strict generated code can throw, map the value to a fallback, or silently drop it, even though the client itself did not change. The root cause is treating every enum in an API spec as closed, when some fields are truly closed state machines and others are open sets of known strings. Teams often disagree about whether a new value is breaking because the openness of each field was never explicitly decided. The recommended fix is to set this in the spec for each field, using closed enums only for genuine state machines where failing loudly is correct. For open categories, generate a tolerant type that keeps known values for convenience while still accepting and preserving any unrecognized string.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in