@stefanprobst/openapi-client
v0.0.3
Published
this is a minimal typed request utility to interact with openapi-specified backends.
Downloads
24
Readme
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" });