# @grafikart/o2ts

> A simple tool to convert OpenAPI 3.0/3.1 specs into a TypeScript file with useful types.

Latest version **0.1.16** (published 2025-07-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install @grafikart/o2ts
pnpm add @grafikart/o2ts
yarn add @grafikart/o2ts
bun add @grafikart/o2ts
```

Provides the command `o2ts`.

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.16 |
| Published | 2025-07-04 |
| First published | 2022-11-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 42 |
| Maintainers | grafikart |

## Links

- npm: https://www.npmjs.com/package/@grafikart/o2ts
- Repository: https://github.com/Grafikart/OpenApiToTS
- Homepage: https://github.com/Grafikart/OpenApiToTS#readme
- Issues: https://github.com/Grafikart/OpenApiToTS/issues
- npm.io page: https://npm.io/package/@grafikart/o2ts

## Dependencies (2)

- [prettier](https://npm.io/package/prettier.md) ^3.6.2
- [@readme/openapi-parser](https://npm.io/package/@readme/openapi-parser.md) ^4.1.0

## Recent versions

- 0.1.16 (latest) — 2025-07-04
- 0.1.15 — 2024-04-03
- 0.1.14 — 2023-10-17
- 0.1.13 — 2023-05-26
- 0.1.12 — 2023-05-26
- 0.1.11 — 2023-05-12
- 0.1.10 — 2023-05-12
- 0.1.9 — 2023-02-26
- 0.1.8 — 2023-01-16
- 0.1.7 — 2023-01-08
- 0.1.6 — 2023-01-08
- 0.1.5 — 2022-11-14
- 0.1.4 — 2022-11-12
- 0.1.3 — 2022-11-11
- 0.1.2 — 2022-11-11

## README

# @grafikart/o2ts

A simple tool to convert OpenAPI 3.0/3.1 specs into a TypeScript file with useful types.

## Install

```bash
npm i -D @grafikart/o2ts
yarn add -D @grafikart/o2ts
pnpm add -D @grafikart/o2ts
```

## Usage

Add the following script to your `package.json`:

```json
{
  "scripts": {
    "openapi": "o2ts ./openapi.yml"
  }
}
```

Then:

```bash
npm run openapi
```

## Example

Here is an example of using the definitions generated with the tool:

```ts
import type { APIPaths, APIRequests, APIResponse } from './openapi'

export async function fetchAPI<
  Path extends APIPaths,
  Options extends APIRequests<Path>
> (path: Path, options: Options): Promise<APIResponse<Path, Options['method']>> {
  // Your code here
}
```

You can find more implementations in the [examples directory](./examples).

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