# @bpinternal/opapi

> Opapi is a highly opinionated library to generate server, client and documentation from OpenAPI specification using typescript.

Latest version **3.0.0** (published 2026-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bpinternal/opapi
pnpm add @bpinternal/opapi
yarn add @bpinternal/opapi
bun add @bpinternal/opapi
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-11-26 |
| First published | 2023-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.0.0 |
| Dependencies | 14 |
| Unpacked size | 246.4 KB |
| Known vulnerabilities | 0 (+37 in 2 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 18 |
| Author | Botpress, Inc. |
| Maintainers | allardy, michael.masson, slvnperron, xavierhamel, botpress-cloud-ops |

## Links

- npm: https://www.npmjs.com/package/@bpinternal/opapi
- Repository: https://github.com/botpress/packages
- Homepage: https://github.com/botpress/packages#readme
- Issues: https://github.com/botpress/packages/issues
- npm.io page: https://npm.io/package/@bpinternal/opapi

## Dependencies (14)

- [axios](https://npm.io/package/axios.md) 1.7.8
- [chalk](https://npm.io/package/chalk.md) 4.1.2
- [execa](https://npm.io/package/execa.md) 8.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [radash](https://npm.io/package/radash.md) 12.1.0
- [verror](https://npm.io/package/verror.md) 1.10.1
- [winston](https://npm.io/package/winston.md) 3.17.0
- [decompress](https://npm.io/package/decompress.md) 4.2.1
- [openapi3-ts](https://npm.io/package/openapi3-ts.md) 2.0.2
- [tsconfig-paths](https://npm.io/package/tsconfig-paths.md) 4.2.0
- [json-schema-to-zod](https://npm.io/package/json-schema-to-zod.md) 2.8.1
- [openapi-typescript](https://npm.io/package/openapi-typescript.md) 6.7.6
- [@readme/openapi-parser](https://npm.io/package/@readme/openapi-parser.md) 2.6.0
- [json-schema-to-typescript](https://npm.io/package/json-schema-to-typescript.md) 13.1.2

## Recent versions

- 3.0.0 (latest) — 2026-11-26
- 3.0.0-rc.0 (next) — 2026-11-26
- 2.0.0 — 2026-07-22
- 1.0.0 — 2025-11-10
- 0.18.0 — 2025-11-07
- 0.17.1 — 2025-11-06
- 0.17.0 — 2025-11-05
- 0.16.1 — 2025-10-29
- 0.16.0 — 2025-10-29
- 0.15.1 — 2025-10-27
- 0.15.0 — 2025-10-22
- 0.14.1 — 2025-07-18
- 0.14.0 — 2025-04-09
- 0.13.0 — 2025-04-01
- 0.12.2 — 2025-02-21
- … 74 more at https://npm.io/package/@bpinternal/opapi/versions

## README

# Opapi (OpenAPI)

> Opapi is a highly opinionated library to generate server, client and documentation from OpenAPI specification using typescript.

## Usage

Install the package and start creating your OpenAPI specification. See the example below

```ts
import { OpenApi, schema } from '@bpinternal/opapi'
import { z } from 'zod'

const api = new OpenApi({
  metadata: {
    title: 'Example API', // This is the title of the API
    description: 'Description of this api', // This is the description of the API
    server: 'https://api.example.com', // This is the base URL of the API
    version: '0.1.0', // This is the version of the API
    prefix: 'v1', // This prefix will be added to all routes
  },
  // This is metadata to be used in the documentation
  section: {
    User: {
      title: 'User',
      description: 'User related endpoints',
    },
  },
  // This is where you define your schemas that will be used in the API
  // You can use the `ref` function to reference a schema
  schemas: {
    User: {
      section: 'User', // This is the section where this schema will be displayed in the documentation
      schema: schema(
        z.object({
          id: z.string(),
          name: z.string(),
        }),
        {
          description: 'User schema',
        },
      ),
    },
  },
  // This is the error definitions that will be used in the API
  errors: [
    {
      status: 403,
      type: 'Forbidden',
      description: "The requested action can't be perform by this resource.",
    },
    {
      status: 400,
      type: 'InvalidPayload',
      description: "The request payload isn't invalid.",
    },
    {
      status: 405,
      type: 'MethodNotFound',
      description: 'The requested method does not exist.',
    },
  ],
})

api.addOperation({
  name: 'listUsers',
  description: 'List all users',
  method: 'get',
  path: '/users',
  section: 'User',
  parameters: {
    name: {
      in: 'query',
      type: 'string',
      description: 'Name filter for the users',
    },
  },
  response: {
    description: 'Returns a list of User objects.',
    schema: z.object({
      users: openapi.getModelRef('User'),
    }),
  },
})

api.exportServer('./gen/server') // This will generate a server that can be used with any framework
api.exportClient('./gen/client') // This will generate a client that can be used to query the API
```

## Disclaimer ⚠️

This package is published under the `@bpinternal` organization. All packages of this organization are meant to be used by the [Botpress](https://github.com/botpress/botpress) team internally and are not meant for our community. Since the packages are catered to our own use-cases, they might have less stable APIs, receive breaking changes without much warning, have minimal documentation and lack community-focused support. However, these packages were still left intentionally public for an important reason : We Love Open-Source. Therefore, if you wish to install or fork this package feel absolutely free to do it. We strongly recommend that you tag your versions properly.

The Botpress Engineering team.

---
_Source: https://npm.io/package/@bpinternal/opapi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
