Show HN: Turn OpenAPI to Universal TypeScript SDKs

  • Hey folks, this was my first major project at Speakeasy! Overall, it's been a great exercise in understanding the sort developer experience customers want from their SDKs. A couple of challenges I want to highlight included translating JSON Schema to Zod schemas (https://zod.dev/) and, frustratingly enough, deciding whether to distribute CommonJS or ESM. On the Zod side, it's been really nice to build on top of a strong schema validation library. It extended the static types we are generating into the runtime in a way. A few customers are using our SDK to detect when their deployed API has drifted from their OpenAPI specs. On the ESM/CJS side, it turns out, _a lot_ of folks (both customers and their users) still want CommonJS. Our testing also showed that bundlers are happy to tree-shake CommonJS code that is side-effect-free and importing CommonJS inside ESM worked just fine so we settled on CJS. We're actually generating source files that contain `import` statements and transpiling, using TypeScript, to CommonJS so we have the option to make this configurable as demand for ESM grows.

    I'll be watching this post and replying to questions :)

  • Nice, congrats!

    This must have been a huge lift – when we launched support for browsers/bun/deno/node/etc along with CJS & ESM from the same npm package, it was a surprising amount of work.

    (disclaimer, we offer a similar service: https://stainlessapi.com)

  • Wow, this is totally awesome! I like that you work with the Bun and Deno runtimes.

  • WOW

  • great stuff!