Skip to content

OpenAPI to Contract ​

If you already have an OpenAPI Specification, you can generate an oRPC contract with Hey API's orpc plugin instead of defining the contract manually.

WARNING

The Hey API orpc plugin is currently beta and may introduce breaking changes while the integration stabilizes.

Example ​

sh
npm install -D @hey-api/openapi-ts
openapi-ts.config.ts
ts
import { defineConfig } from '@hey-api/openapi-ts'

export default defineConfig({
  input: 'https://get.heyapi.dev/hey-api/backend',
  output: 'src/client',
  plugins: [
    {
      name: 'orpc',
      validator: {
        input: 'zod',
      },
    },
  ],
})

Then run:

sh
npx @hey-api/openapi-ts

This generates an oRPC-compatible contract from your OpenAPI specification. In this example, zod is used for generated input validation.

For more details about configuration options and plugin behavior, see the Hey API oRPC plugin documentation.

What To Do Next ​

Once the contract is generated, what you do next depends on how you want to use it:

Released under the MIT License.