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/sdkQuickstart
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
| Export | Description |
|---|---|
paths | OpenAPI paths object, keyed by URL pattern then HTTP method. Useful for typed routers. |
operations | OpenAPI operations object, keyed by operationId. |
components | OpenAPI components object (schemas, parameters, etc). |
webhooks | OpenAPI webhooks object (empty for Aero2 today). |
Schemas | Convenience: 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
/serveror/browserwhen 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
/typeswhen you are calling Aero2 directly withfetch(or a typed HTTP client likeopenapi-fetch) and just want strong types on the wire. Example: an admin tool that hits/api/clientsdirectly.
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 driftThe 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.