Open enums and smart unions in Ruby SDKs
Blog post from Speakeasy
Ruby SDKs generated by Speakeasy have introduced open enums and smart union deserialization to enhance compatibility and flexibility when interacting with evolving APIs. Open enums allow older SDK versions to handle new enum values without crashing by treating unrecognized values as raw strings, while smart union deserialization improves the selection of appropriate union variants by considering the number of matching fields rather than relying on declaration order. These features ensure that SDKs remain operational as APIs evolve, eliminating the need for users to modify their code to accommodate new enum values or union variants. By default, response enums can be configured to be open, and the populated-fields strategy for union deserialization can be set to prioritize variants with the most field matches, providing a robust solution for handling API changes seamlessly.