0.1.15 • Published 1 month ago

@grafikart/o2ts v0.1.15

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

@grafikart/o2ts

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

Install

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

Usage

Add the following script to your package.json:

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

Then:

npm run openapi

Example

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

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.

0.1.15

1 month ago

0.1.14

7 months ago

0.1.10

12 months ago

0.1.11

12 months ago

0.1.12

12 months ago

0.1.13

12 months ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago