feat(ruby): add support for discriminated unions, enums, and undiscriminated unions in dynamic snippets #11099
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refs FER-7972
Implements three previously unimplemented type converters in the Ruby v2 dynamic snippets generator. These converters were returning
nop()(no operation), causing snippet examples to show empty arrays or missing values for complex types like union recipients in email/message send operations.Changes Made
convertDiscriminatedUnionto handle discriminated union types by resolving the union variant and converting its properties to a Ruby hashconvertEnumto convert enum values to Ruby strings using the wire valueconvertUndiscriminatedUnionto try each variant type until one matches the value structureconvertDiscriminatedUnionProperties,convertObjectToHashEntries,getEnumValueName,findMatchingUndiscriminatedUnionTypegetBodyArgsForNonObjectTypein EndpointSnippetGenerator to handle non-object request body types (arrays, undiscriminated unions, aliases)convert()again on the main contextconvertObjectToHashEntrieshelper to properly handlesamePropertiesAsObjectdiscriminated unions (removed the stubextractHashEntriesmethod)Testing
pnpm run check)Snapshot diff examples:
Human Review Checklist
Critical: TheRESOLVED: ImplementedextractHashEntriesmethod was a stub that always returnedundefined.convertObjectToHashEntrieshelper that properly handlessamePropertiesAsObjectdiscriminated unions.getBodyArgsForNonObjectTypemethod uses hardcoded"request"as the keyword argument name for non-object body types. Verify this matches the actual Ruby SDK method signatures for endpoints with array/union request bodies.senders.resolve()andsender_pools.add_sender()endpoints, the snippets still show empty/minimal parameters. This is a version mismatch issue - Twilio config uses version 1.0.0-rc60, but these fixes are in 1.0.0-rc62. Once the new version is published and Twilio regenerates, thetoarrays should be populated.Link to Devin run: https://app.devin.ai/sessions/b477dd9fc0ea40209f2f32050aad3768
Requested by: [email protected] (@iamnamananand996)