/docs

Full stack typesafe API-first development with OpenAPI.

Primary LanguageTypeScriptMIT LicenseMIT

openapi-stack

Full stack typesafe API-first development for REST.

License npm downloads npm downloads Buy me a coffee

openapi-stack is a collection of open source libraries and tools for full stack software development using OpenAPI specification with an API Design First philosophy.

The goal is to unlock great developer experience and full stack type safety for software teams using REST; inspired by tools like GraphQL and tRPC.

Benefits

  1. 🚀 No code generation. Write your own code the way you like it. Only generate types from OpenAPI spec if you want.
  2. 🤝 Single source of truth for your API contract. No more manually updating your OpenAPI specs to keep up with your backend code. Ensure your API docs and SDKs stay up to date by using the spec in runtime to route and validate.
  3. 🧙‍♂️ Type safety and validation. Build your product faster and with a better developer experience using strongly typed Typescript and code autocomplete both in the server and client side.
  4. ❤️ Testing & Collaboration. Leverage API mocks to make testing and development easier and iterate fast on your API design as you build your app's interface. Being blocked by the backend team is a thing of the past!

Packages part of openapi-stack:

Comparisons

How does openapi-stack compare to GraphQL?

GraphQL is a query language for APIs developed by Facebook. It gives API clients full control over the data they query, making it extremely flexible and efficient for client-centric use cases.

Similar to OpenAPI specification, GraphQL APIs define a strongly typed schema for the data and mutations they support which makes them discoverable and intuitive to develop against.

OpenAPI stack achieves the same type safety and great developer experience by using the OpenAPI specification as a single source of truth for the API contract, used to generate types for both client and server side and utilising it for routing and validation during runtime.

Both GraphQL and openapi-stack encourage an API First approach where the API contract is treated as a first class citizen in software design instead of treating it as merely documentation.

While REST APIs don't generally provide the same level of control to clients as GraphQL, many times this could be seen as a benefit especially in scenarios where strict control over data access and operations is crucial.

Many organizations choose REST over GraphQL due to more established conventions, simplicity, and the ability to leverage standard HTTP features directly. Widespread knowledge around REST contribute to its choice among organizations looking for a tried-and-tested approach to building APIs.

How does openapi-stack compare to tRPC?

tRPC is a Remote Procedure Call (RPC) library for Typescript to build and consume typesafe APIs.

Designed for full-stack Typescript applications, tRPC allows direct sharing of types between both the client and server, without relying on code generation.

Unlike GraphQL and REST, tRPC doesn't expose a standard machine-readable API schema to be consumed by clients, instead taking a more straightforward approach of exposing endpoints or procedures, essentially "just functions" invoked by the client to the server.

OpenAPI stack achieves type safety using a similar workflow to tRPC's procedures with OpenAPI operations, also avoiding code generation by only generating types from OpenAPI spec and using the machine readable contract in the runtime for routing and validation.

While the lightweight tRPC approach is optimal for teams just looking to build full stack applications, teams looking to build robust APIs are better served by the API design first approach of openapi-stack or GraphQL.

Features

  • Battle-tested in production. High test coverage.
  • ️No code generation – we only generate types
  • Built with TypeScript, types included with full autocomplete support
  • Framework agnostic – works with your stack
  • Lightweight - small frontend bundle + optimized for serverless cold starts
  • OpenAPI 3.x support
  • Samples included

Star History

Star History Chart

Commercial support

For assistance with integrating openapi-stack for your company, reach out at support@openapistack.co.

Contributing

OpenAPI Stack is Free and Open Source Software. Issues and pull requests are more than welcome!