TypeScript Types
Every field, every schema, every response — typed perfectly. Invokix generates clean, idiomatic TypeScript types directly from your contract and keeps them in sync every time you publish.
What gets generated
Invokix reads your OpenAPI contract and produces a single types.ts file with a named export for every schema in your contract. Types are clean and idiomatic — no wrappers, no classes, no generated noise. Just pure TypeScript that feels like you wrote it yourself.
// Auto-generated by Invokix — do not edit manually
// Contract: Orders API v1.2 — published March 5, 2025
export type Order = {
id: string
price: number
status: "pending" | "shipped" | "delivered" | "cancelled"
userId: string
createdAt: string
lineItems: LineItem[]
}
export type LineItem = {
id: string
productId: string
quantity: number
price: number
}
export type CreateOrderBody = {
price: number
lineItems: Array<{
productId: string
quantity: number
price: number
}>
}
export type UpdateOrderBody = {
status?: "shipped" | "delivered" | "cancelled"
}
export type PaginatedOrders = {
orders: Order[]
total: number
page: number
pageSize: number
}How to use generated types
Copy the output from the Types tab and paste it into your project. Or use the CLI to pull it directly — the file is always named after your contract and placed in src/types/.
import type { Order, CreateOrderBody } from "@/types/orders"
// Pass Order type directly to any function or component
async function fetchOrder(id: string): Promise<Order> {
const res = await fetch("/api/orders/" + id)
return res.json()
}
// TypeScript catches wrong shapes at compile time
async function createOrder(body: CreateOrderBody): Promise<Order> {
const res = await fetch("/api/orders", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
})
return res.json()
}
// Type your state directly
const [orders, setOrders] = useState<Order[]>([])
const [selected, setSelected] = useState<Order | null>(null)How types map from OpenAPI
| OpenAPI type | TypeScript type |
|---|---|
string | string |
number, integer | number |
boolean | boolean |
string with enum | "value1" | "value2" |
array of schema | SchemaName[] |
nullable: true | Type | null |
required fields | Non-optional properties |
| Optional fields | field?: Type |
Staying in sync
When you publish a new contract version, your types change. Invokix notifies your team the moment this happens — with the exact file and line that references the old type.
Use the CLI to always pull the latest version into your project without opening a browser:
npx invokix pull
✔ Authenticated
✔ Contract: Orders API v1.3
✔ Writing: src/types/orders.ts
✔ Writing: src/hooks/useOrders.ts
✔ Writing: src/schemas/orders.ts
All outputs synced to v1.3