Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

OpenAPI Types — @aero2/sdk/types

Auto-generated TypeScript types for the Aero2 HTTP API, generated from the live OpenAPI spec. Use these to type request bodies, response bodies, and shared schemas when you call Aero2 directly with fetch or another HTTP client — no runtime cost, types only.

The types are regenerated by CI from docs/public/openapi.json and shipped as part of the published @aero2/sdk package. A freshness check in CI fails the build if the committed types drift from the spec.

Install

@aero2/sdk/types ships in the same package as the rest of the SDK:

npm install @aero2/sdk

Quickstart

import type { Schemas, ResponseBody, RequestBody } from "@aero2/sdk/types";
 
// Named component schemas
const discovery: Schemas["OIDCDiscovery"] = await (
  await fetch("https://your-app.aero2.dev/.well-known/openid-configuration")
).json();
 
// Response body for an operation, looked up by operationId + status
type TokenResponse = ResponseBody<"token", 200>;
 
// Request body for an operation (form-encoded for the token endpoint)
type TokenRequest = RequestBody<"token", "application/x-www-form-urlencoded">;

What's exported

ExportDescription
pathsOpenAPI paths object, keyed by URL pattern then HTTP method. Useful for typed routers.
operationsOpenAPI operations object, keyed by operationId.
componentsOpenAPI components object (schemas, parameters, etc).
webhooksOpenAPI webhooks object (empty for Aero2 today).
SchemasConvenience: components["schemas"]. Index by schema name.
RequestBody<Op, Content?>Look up an operation's request body by operationId. Defaults to application/json.
ResponseBody<Op, Status?, Content?>Look up an operation's response body. Defaults to status 200, application/json.

When to use this vs. @aero2/sdk/server or @aero2/sdk/browser

  • Use /server or /browser when there is a primitive that covers your case — token verification, M2M, PKCE login. Those wrap the HTTP details and handle JWKS caching, refresh, etc.
  • Use /types when you are calling Aero2 directly with fetch (or a typed HTTP client like openapi-fetch) and just want strong types on the wire. Example: an admin tool that hits /api/clients directly.

With openapi-fetch

import createClient from "openapi-fetch";
import type { paths } from "@aero2/sdk/types";
 
const client = createClient<paths>({
  baseUrl: "https://your-app.aero2.dev",
  headers: { Authorization: `Bearer ${token}` },
});
 
const { data, error } = await client.GET("/api/clients");
//        ^? { clients: components["schemas"]["Client"][] }

Regenerating locally

Inside the sdk/ workspace:

npm run generate:types     # writes src/types/openapi.d.ts
npm run check:types-fresh  # what CI runs; fails on drift

The committed src/types/openapi.d.ts is what's published — there is no codegen at install time. The CI freshness check guarantees that the file on disk matches what the current spec would produce.