Skip to content

feat(stripe): Add types for v20.0 - #1081

Merged
github-actions[bot] merged 1 commit into
ruby:mainfrom
ksss:stripe-20.0
Oct 10, 2026
Merged

github-actions[bot] merged 1 commit into
ruby:mainfrom
ksss:stripe-20.0

Conversation

@ksss

@ksss ksss commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

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

ruby gems/stripe/20.0/_generator/generate.rb 20.0.0

The script rewrites stripe/**/*.rbs from two inputs:

  • stripe-ruby at the v20.0.0 tag. It converts its Sorbet RBI files with rbs prototype rbi. The tag is used instead of the released gem because the gem ships only part of rbi/.
  • The public OpenAPI spec (stripe/openapi latest/openapi.spec3.json) at the tag named by stripe-ruby's OPENAPI_VERSION.

stripe.rbs is 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

  • Keeps only documented API. The RBI comes from the SDK flavour of the spec, which also carries deprecated and unreleased fields. Resources and fields missing from the public spec are dropped, which matches what https://docs.stripe.com/api lists. This removes 6 resources and 72 fields.
  • Types collection elements from the spec. For example, Customer.list returns ListObject[Customer], Invoice#lines returns ListObject[InvoiceLineItem], and client.v1.customers.search returns SearchResultObject[Customer].
  • Follows runtime behaviour where the RBI disagrees:
    • Hash-typed fields such as metadata and currency_options become StripeObject, because the SDK converts every response Hash into one with Symbol keys. Calls like metadata.fetch or key? raise NoMethodError, and now fail type checking instead.
    • Event::Data#object is untyped, since it holds whichever resource the event is about.
    • fetch_related_object on thin events is also untyped, for the same reason.
  • Types client.v1.* / client.v2.*. Service readers have no sig in the RBI, so their types are read from the Ruby source instead.
  • Simplifies the rest:
    • *Params classes are dropped, and request params are typed as Hash[untyped, untyped]. Typed params could come back as overloads on request.
    • opts is typed as Stripe::request_opts, which is String | Hash[Symbol, untyped].
    • Doc comments, instance variables and private methods are dropped.

The result is 605 files and about 920KB, down from 10MB of RBI.

Testing

  • _test/test.rb follows Stripe's own samples, including the snapshot and thin webhook handlers from https://docs.stripe.com/webhooks.
  • bin/test gems/stripe/20.0 passes, with no untyped calls.
  • rubocop gems/stripe/20.0 passes.

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown

@ksss Thanks for your contribution!

Please follow the instructions below for each change.
See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.

  • /merge: Merge this PR if CI passes

stripe

You changed RBS files for an existing gem.
You can merge this PR yourself because you are a reviewer of this gem.
Just comment /merge to merge this PR.

You can also request a review from other reviewers if you want.

@ksss

ksss commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator Author

/merge

@github-actions
github-actions Bot merged commit 8e2b896 into ruby:main Oct 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant