Evolving enums for evolving APIs
Blog post from Speakeasy
Speakeasy has introduced support for "open" enums in their Go, Python, and TypeScript SDK generators to accommodate evolving APIs without causing dependency management issues for users. Traditional "closed" enums restrict values to a predefined set, posing challenges when APIs are updated with new values, such as adding a new category in a content management system API. By using the x-speakeasy-unknown-values extension in OpenAPI, developers can mark certain enums as open, allowing for unrecognized values to be handled gracefully. This approach ensures that SDKs remain functional and type-safe even as APIs evolve, while maintaining a robust developer experience with features like editor auto-complete. This enhancement aims to address longstanding challenges in handling enums within APIs, providing a flexible solution that allows API evolution without disrupting existing users.