@orbitwrite/openapi
v0.0.8
Published
Generated TypeScript types for the Orbitwrite API (/api/v1).
Readme
@orbitwrite/openapi
TypeScript types for the Orbitwrite API, generated from its OpenAPI document. Types only — there is no runtime here.
npm install @orbitwrite/openapiMost people want @orbitwrite/sdk,
which re-exports everything below and adds a client. Reach for this package
directly when you are calling the API with your own fetch, or generating a
client in another shape.
import type {
ConnectedAccountList,
PostListEntry,
RequestBody,
paths,
} from "@orbitwrite/openapi";
// Named aliases for the common schemas
const accounts: ConnectedAccountList = await res.json();
// Or reach any operation by path and method
type CreatePostsBody = RequestBody<"/api/v1/posts", "post">;paths, components, operations and webhooks are the raw
openapi-typescript output, so anything built on those conventions — including
openapi-fetch — works directly:
import createClient from "openapi-fetch";
import type { paths } from "@orbitwrite/openapi";
const client = createClient<paths>({ baseUrl: "https://orbitwrite.com" });The live spec is at orbitwrite.com/api/v1/openapi.json and the interactive docs at orbitwrite.com/api/v1/docs.
Regenerating
src/schema.ts is generated and must never be edited by hand. From the repo
root, after changing any /api/v1 route schema:
pnpm api:codegen