OpenAPI → TypeScript (2026)
Generate TypeScript interfaces and types from your OpenAPI / Swagger components.schemas. Handles enums, $refs, oneOf/anyOf/allOf, nullable, and arrays. Copy the result straight into your project.
/**
* Generated by Specway — https://specway.com/tools/openapi-to-typescript
* Edit your OpenAPI spec, not this file.
*/
export interface User {
id: number;
email: string;
name?: string;
role?: "admin" | "member" | "guest";
tags?: string[];
team?: Team;
}
export interface Team {
id: string;
name: string;
memberCount?: number;
}
What gets generated
- One
interfaceper object schema incomponents.schemas(ordefinitionsfor Swagger 2.0). typealiases for enums and primitive schemas.- Optional fields (
?:) for anything not inrequired. - Union types for
oneOfandanyOf; intersection types forallOf. $refreferences resolve to the named interface.nullable: trueappends| null.
When to use this vs openapi-typescript
This widget is for the one-off: someone sent you a spec in Slack, you need types in your editor right now. Paste, copy, done.
For production: openapi-typescript
For ongoing projects, install openapi-typescript as a dev dep:
npm i -D openapi-typescript npx openapi-typescript spec.yaml -o src/api.d.ts
Pair with openapi-fetch for fully-typed request/response handling. Or use Specway — auto- generated types are part of every docs publish.