npm.io
0.0.3 • Published 2 years ago

@stefanprobst/openapi-client

Licence
MIT
Version
0.0.3
Deps
2
Size
18 kB
Vulns
0
Weekly
0

openapi-client

this is a minimal typed request utility to interact with openapi-specified backends.

it uses openapi-typescript for generating types, and is mostly copied from openapi-fetch.

how to install

npm install @stefanprobst/openapi-client

how to use

first, generate types from an openapi document:

npx openapi-typescript https://my-backend.org/openapi.json -o ./types/api.ts

second, instantiate a typed api client:

import { createClient } from "@stefanprobst/openapi-client";

import type { paths } from "./types/api";

const client = createClient<paths>({ baseUrl: "http://localhost:3000" });