Add runtime support for V2 int64 string-encoded fields#1814
Merged
mbroshi-stripe merged 3 commits intomasterfrom Mar 18, 2026
Merged
Add runtime support for V2 int64 string-encoded fields#1814mbroshi-stripe merged 3 commits intomasterfrom
mbroshi-stripe merged 3 commits intomasterfrom
Conversation
ae1145c to
b6ec428
Compare
There was a problem hiding this comment.
Pull request overview
Adds request-side runtime coercion so V2 int64 fields are serialized as JSON strings (to match V2 wire format), complementing existing response-side decoding.
Changes:
- Adds
field_encodings,coerce_value, andcoerce_paramstoStripe::RequestParamsand applies coercion during#to_h. - Introduces recursive encoding schemas for nested objects/arrays, with
:int64_stringleaf handling. - Expands
RequestParamsunit tests to cover new coercion behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lib/stripe/request_params.rb |
Implements encoding schema support and coercion helpers for request serialization. |
test/stripe/request_params_test.rb |
Adds tests validating scalar/array/object coercion and #to_h integration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a8fc711 to
9ed5327
Compare
xavdid-stripe
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why?
V2 APIs represent int64 fields as JSON strings on the wire (e.g.
"12345"instead of12345) to avoid precision loss. The SDK should transparently convert between native RubyIntegerand this wire format so users don't need to handle string encoding themselves.What?
field_encodingsclass method andcoerce_value/coerce_paramshelpers toRequestParamsfor request-side coercion (Integer → String), handling scalars, nested objects, and arraysfield_encodingson V2 params classes and callcoerce_paramsin service methods for Hash-typed paramsStripeObject#field_encodings(existing pattern from codegen)