Show HN: Turn OpenAPI to Universal TypeScript SDKs
27 points| simplesager | 2 years ago |speakeasyapi.dev
There are a number of open source generators out there but none of them provided enough coverage across the variety of APIs we see modelled with OpenAPI. Some of the requirements we tried to hit in this release:
- Compatibility with the browser & server
- Support for popular, backend JavaScript runtimes including Node.js, Bun, Deno
- User input and server response validation with Zod
- Support for polymorphic types, also known as unions or `oneOf` in OpenAPI.
- Support for constant and default values, big integers and decimals
- Support for multipart streaming upload
- Support for server sent events using native OpenAPI constructs
We want to give a special shout out to Zod because it served as a great foundation for translating all the JSON Schema primitives used in OpenAPI into TypeScript types that you can trust. By this we mean that the types are backed by runtime validation so vanilla JS users have a safeguard and servers that drift from their OpenAPI spec are caught instead of silently failing or triggering obscure runtime errors. If you’re curious to dive into our learnings check out this post https://www.speakeasyapi.dev/post/how-we-built-universal-ts
We’d love for folks to check out our new generator and give us feedback. Its really easy to get started. Install our CLI with `brew install speakeasy-api/homebrew-tap/speakeasy` and run `speakeasy generate sdk -s openapi.yaml --output ./sdk -l typescript` . If you want to chat directly with us you can reach us on slack : https://join.slack.com/t/speakeasy-dev/shared_invite/zt-1cwb... .
disintegrator|2 years ago
I'll be watching this post and replying to questions :)
rattray|2 years ago
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)
asmyers1793|2 years ago
napolux|2 years ago
anagpal|2 years ago