Regenerate with decimal_string enabled for v2 APIs#2187
Merged
jar-stripe merged 4 commits intomasterfrom Mar 20, 2026
Merged
Conversation
V2 API fields with `format: decimal` now generate as `BigDecimal` instead of `String`. Driven by sdk-codegen#3369. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
The V2 API expects decimal fields as JSON strings (e.g., "25.5") not JSON numbers. Add a custom Gson TypeAdapter for BigDecimal to BODY_GSON that serializes via toPlainString(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
4428859 to
c1b2f96
Compare
Contributor
prathmesh-stripe
left a comment
There was a problem hiding this comment.
Can you regenerate this from latest codegen master? Fix for the broken test should be in codegen now.
prathmesh-stripe
approved these changes
Mar 20, 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 API decimal fields (e.g.
amounton billing meter events) were previously generated as plainStringtypes, even though the same fields in v1 are generated asBigDecimal. A codegen workaround suppresseddecimal_stringtype mapping for all v2 APIs. That workaround has been removed.What?
decimal_stringenabled for v2 APIsBigDecimalinstead ofString, matching v1 behaviorTypeAdapter<BigDecimal>toJsonEncoder.BODY_GSONthat serializesBigDecimalas a JSON string (e.g.,"75.25"not75.25). The V2 API expects decimal fields as strings on the wire. V1 doesn't hit this becauseFormEncodercalls.toString()naturally.Testing
Integration tested against a live Stripe sandbox (6/6 tests passed):
BigDecimaldeserialization from Gson JSON string ✓BigDecimalnull when field absent ✓BigDecimalhigh precision (10 decimal places) ✓Amountconsolidation (sharedv2.Amountclass) ✓BigDecimalpercentOwnership ✓BigDecimalpercentOwnership ✓See Also
Changelog
percentOwnershiponV2.Core.Account) changed type fromStringtoBigDecimal. Code that reads or writes these fields asStringwill need to useBigDecimalinstead.