Skip to content

Comment on Show HN: Turn OpenAPI to Universal TypeScript SDKs

Comments

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 :)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.