In this episode of Build and Learn, we discuss code generation (codegen) and how Stripe uses it to generate SDKs for its APIs automatically. We talk about how a declarative shape of an API (such as Open API spec or GraphQL schema) can be fed into a tool to generate an SDK in a specific programming language. This process helps ensure that the SDKs are always in sync with the API and that any changes to the API are automatically reflected in the SDKs.
Most SDKs today are still hand-written, but automatic generation is becoming more popular.
We'll touch on the tradeoff between readable code and automatically generated code, which can be quite long and complex.
You'll also hear how the Ruby clients for Orbit were likely written by hand and may not be up-to-date.
- Richard Marmorstein's Strangeloop talk about codegen: https://www.youtube.com/watch?v=mgRreyw-Nlg
- CJ's RubyConf 2022 talk about codegen: https://www.youtube.com/watch?v=sm0fgIqfsO8
- Stainless API company: https://stainlessapi.com/
- Open API Spec: https://swagger.io/specification/
- Stripe API Spec: https://github.com/stripe/openapi
- Swagger codegen: https://swagger.io/tools/swagger-codegen/
- Orbit Ruby Activities gem: https://github.com/orbit-love/ruby-orbit-activities