Repository navigation
feat(stripe): Add types for v20.0 - #1081
Merged
Merged
Conversation
Signatures under stripe/ are generated by _generator/generate.rb from the Sorbet RBI files in stripe-ruby v20.0.0 and the public OpenAPI spec it was built from. stripe.rbs holds the hand-written core (configuration, StripeObject, ListObject, StripeClient, errors). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@ksss Thanks for your contribution! Please follow the instructions below for each change. Available commandsYou can use the following commands by commenting on this PR.
|
Collaborator
Author
|
/merge |
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.
https://github.com/stripe/stripe-ruby
Adds signatures for stripe v20.0. Unlike 13.0, which was written by hand for a handful of resources, this covers the whole SDK and is generated by a script so it can follow future releases.
How it is generated
The script rewrites
stripe/**/*.rbsfrom two inputs:v20.0.0tag. It converts its Sorbet RBI files withrbs prototype rbi. The tag is used instead of the released gem because the gem ships only part ofrbi/.stripe/openapilatest/openapi.spec3.json) at the tag named by stripe-ruby'sOPENAPI_VERSION.stripe.rbsis hand-written and not touched by the script. It covers configuration (Stripe.api_key=etc.),StripeObject,ListObject[T],StripeClient, errors and a few v2 event helpers.What the script does on top of the RBI
Customer.listreturnsListObject[Customer],Invoice#linesreturnsListObject[InvoiceLineItem], andclient.v1.customers.searchreturnsSearchResultObject[Customer].metadataandcurrency_optionsbecomeStripeObject, because the SDK converts every response Hash into one with Symbol keys. Calls likemetadata.fetchorkey?raiseNoMethodError, and now fail type checking instead.Event::Data#objectisuntyped, since it holds whichever resource the event is about.fetch_related_objecton thin events is alsountyped, for the same reason.client.v1.*/client.v2.*. Service readers have no sig in the RBI, so their types are read from the Ruby source instead.*Paramsclasses are dropped, and request params are typed asHash[untyped, untyped]. Typed params could come back as overloads on request.optsis typed asStripe::request_opts, which isString | Hash[Symbol, untyped].The result is 605 files and about 920KB, down from 10MB of RBI.
Testing
_test/test.rbfollows Stripe's own samples, including the snapshot and thin webhook handlers from https://docs.stripe.com/webhooks.bin/test gems/stripe/20.0passes, with no untyped calls.rubocop gems/stripe/20.0passes.🤖 Generated with Claude Code