New advertisers: 50% off your first month with code FIRSTMONTHSee slots
softaworks avatar

openapi-to-typescript

Type generator that turns OpenAPI 3.0 specs into TypeScript interfaces and runtime type guards.

GitHub stars
2.7K
View on GitHub

What it does

  • Converts OpenAPI 3.0 JSON and YAML schemas into TypeScript interfaces and type guards
  • Runs as a single skill, openapi-to-typescript, triggered by requests to generate types or API interfaces
  • Designed for projects that need typed API clients generated from an existing OpenAPI specification

Converts OpenAPI 3.0 JSON/YAML to TypeScript interfaces and type guards. Use when generating types from OpenAPI or creating API interfaces.

Add marketplace

/plugin marketplace add softaworks/agent-toolkit

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install openapi-to-typescript@agent-toolkit

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

OpenAPI to TypeScript

Converts OpenAPI 3.0 specifications to TypeScript interfaces and type guards.

Input: OpenAPI file (JSON or YAML) Output: TypeScript file with interfaces and type guards

When to Use

  • "generate types from openapi"
  • "convert openapi to typescript"
  • "create API interfaces"
  • "generate types from spec"

Workflow

  1. Request the OpenAPI file path (if not provided)
  2. Read and validate the file (must be OpenAPI 3.0.x)
  3. Extract schemas from components/schemas
  4. Extract endpoints from paths (request/response types)
  5. Generate TypeScript (interfaces + type guards)
  6. Ask where to save (default: types/api.ts in current directory)
  7. Write the file

OpenAPI Validation

Check before processing:

- Field "openapi" must exist and start with "3.0"
- Field "paths" must exist
- Field "components.schemas" must exist (if there are types)

If invalid, report the error and stop.

Type Mapping

Primitives

OpenAPITypeScript
stringstring
numbernumber
integernumber
booleanboolean
nullnull

Format Modifiers

FormatTypeScript
uuidstring (comment UUID)
datestring (comment date)
date-timestring (comment ISO)
emailstring (comment email)
uristring (comment URI)

Complex Types

Object:

// OpenAPI: type: object, properties: {id, name}, required: [id]
interface Example {
  id: string;      // required: no ?
  name?: string;   // optional: with ?
}

Array:

// OpenAPI: type: array, items: {type: string}
type Names = string[];

Enum:

// OpenAPI: type: string, enum: [active, draft]
type Status = "active" | "draft";

oneOf (Union):

// OpenAPI: oneOf: [{$ref: Cat}, {$ref: Dog}]
type Pet = Cat | Dog;

allOf (Intersection/Extends):

// OpenAPI: allOf: [{$ref: Base}, {type: object, properties: ...}]
interface Extended extends Base {
  extraField: string;
}

Code Generation

File Header

/**
 * Auto-generated from: {source_file}
 * Generated at: {timestamp}
 *
 * DO NOT EDIT MANUALLY - Regenerate from OpenAPI schema
 */

Interfaces (from components/schemas)

For each schema in components/schemas:

export interface Product {
  /** Product unique identifier */
  id: string;

  /** Product title */
  title: string;

  /** Product price */
  price: number;

  /** Created timestamp */
  created_at?: string;
}
  • Use OpenAPI description as JSDoc
  • Fields in required[] have no ?
  • Fields outside required[] have ?

Request/Response Types (from paths)

For each endpoint in paths:

// GET /products - query params
export interface GetProductsRequest {
  page?: number;
  limit?: number;
}

// GET /products - response 200
export type GetProductsResponse = ProductList;

// POST /products - request body
export interface CreateProductRequest {
  title: string;
  price: number;
}

// POST /products - response 201
export type CreateProductResponse = Product;

Naming convention:

  • {Method}{Path}Request for params/body
  • {Method}{Path}Response for response

Type Guards

For each main interface, generate a type guard:

export function isProduct(value: unknown): value is Product {
  return (
    typeof value === 'object' &&
    value !== null &&
    'id' in value &&
    typeof (value as any).id === 'string' &&
    'title' in value &&
    typeof (value as any).title === 'string' &&
    'price' in value &&
    typeof (value as any).price === 'number'
  );
}

Type guard rules:

  • Check typeof value === 'object' && value !== null
  • For each required field: check 'field' in value
  • For primitive fields: check typeof
  • For arrays: check Array.isArray()
  • For enums: check .includes()

Error Type (always include)

export interface ApiError {
  status: number;
  error: string;
  detail?: string;
}

export function isApiError(value: unknown): value is ApiError {
  return (
    typeof value === 'object' &&
    value !== null &&
    'status' in value &&
    typeof (value as any).status === 'number' &&
    'error' in value &&
    typeof (value as any).error === 'string'
  );
}

$ref Resolution

When encountering {"$ref": "#/components/schemas/Product"}:

  1. Extract the schema name (Product)
  2. Use the type directly (don't resolve inline)
// OpenAPI: items: {$ref: "#/components/schemas/Product"}
// TypeScript:
items: Product[]  // reference, not inline

Complete Example

Input (OpenAPI):

{
  "openapi": "3.0.0",
  "components": {
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "email": {"type": "string", "format": "email"},
          "role": {"type": "string", "enum": ["admin", "user"]}
        },
        "required": ["id", "email", "role"]
      }
    }
  },
  "paths": {
    "/users/{id}": {
      "get": {
        "parameters": [{"name": "id", "in": "path", "required": true}],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {"$ref": "#/components/schemas/User"}
              }
            }
          }
        }
      }
    }
  }
}

Output (TypeScript):

/**
 * Auto-generated from: api.openapi.json
 * Generated at: 2025-01-15T10:30:00Z
 *
 * DO NOT EDIT MANUALLY - Regenerate from OpenAPI schema
 */

// ============================================================================
// Types
// ============================================================================

export type UserRole = "admin" | "user";

export interface User {
  /** UUID */
  id: string;

  /** Email */
  email: string;

  role: UserRole;
}

// ============================================================================
// Request/Response Types
// ============================================================================

export interface GetUserByIdRequest {
  id: string;
}

export type GetUserByIdResponse = User;

// ============================================================================
// Type Guards
// ============================================================================

export function isUser(value: unknown): value is User {
  return (
    typeof value === 'object' &&
    value !== null &&
    'id' in value &&
    typeof (value as any).id === 'string' &&
    'email' in value &&
    typeof (value as any).email === 'string' &&
    'role' in value &&
    ['admin', 'user'].includes((value as any).role)
  );
}

// ============================================================================
// Error Types
// ============================================================================

export interface ApiError {
  status: number;
  error: string;
  detail?: string;
}

export function isApiError(value: unknown): value is ApiError {
  return (
    typeof value === 'object' &&
    value !== null &&
    'status' in value &&
    typeof (value as any).status === 'number' &&
    'error' in value &&
    typeof (value as any).error === 'string'
  );
}

Common Errors

ErrorAction
OpenAPI version != 3.0.xReport that only 3.0 is supported
$ref not foundList missing refs
Unknown typeUse unknown and warn
Circular referenceUse type alias with lazy reference

From the softaworks/agent-toolkit README

Softaworks Agent Skills

Opinionated skills shared by @leonardocouy for improving daily work efficiency with Claude Code. Skills are packaged instructions and scripts that extend agent capabilities across development, documentation, planning, and professional workflows.

Skills follow the Agent Skills format.


๐Ÿงญ Quick Navigation

๐Ÿš€ Installation โ€ข ๐Ÿ“š Available Skills โ€ข ๐Ÿค– Agents & Commands โ€ข ๐Ÿ“– Skill Structure โ€ข ๐Ÿค Contributing โ€ข ๐Ÿ“„ License โ€ข ๐Ÿ”— Links


๐Ÿš€ Installation

Quick Install (Recommended)

npx skills add softaworks/agent-toolkit

This method works with multiple AI coding agents (Claude Code, Codex, Cursor, AdaL, etc.)

Register as Plugin Marketplace

Run the following commands in Claude Code:

/plugin marketplace add softaworks/agent-toolkit
/plugin

Install Plugins

Option 1: Via Browse UI

  1. Switch to Marketplaces tab (use arrow keys or Tab)
  2. Select agent-toolkit, press Enter
  3. Browse and select the plugin(s) you want to install
  4. Select Install now

Option 2: Direct Install

# Install specific skill
/plugin install codex@agent-toolkit
/plugin install humanizer@agent-toolkit

# Install specific agent
/plugin install agent-codebase-pattern-finder@agent-toolkit

# Install specific command
/plugin install command-codex-plan@agent-toolkit

Option 3: Ask the Agent

Simply tell Claude Code:

Please install Skills from github.com/softaworks/agent-toolkit

Available Plugins

Each skill, agent, and command is an individual plugin that can be installed separately:

  • Skills โ†’ See Available Skills for the full list
  • Agents โ†’ See Agents (install as agent-<name>@agent-toolkit)
  • Commands โ†’ See Slash Commands (install as command-<name>@agent-toolkit)

Update Plugins

To update plugins to the latest version:

  1. Run /plugin in Claude Code
  2. Switch to Marketplaces tab
  3. Select agent-toolkit
  4. Choose Update marketplace

You can also Enable auto-update to get the latest versions automatically.

Manual Installation

For Claude Code (Manual) โ€” Skills only

cp -r skills/<skill-name> ~/.claude/skills/

For claude.ai โ€” Skills only

Add skills to project knowledge or paste SKILL.md contents into the conversation.


๐Ÿ“š Available Skills

CategorySkillDescription
๐Ÿค– AI ToolscodexAdvanced code analysis with GPT-5.2
๐Ÿค– AI ToolsgeminiLarge-scale review (200k+ context)
๐Ÿค– AI ToolsperplexityWeb search & research
๐Ÿ”ฎ Metaagent-md-refactorRefactor bloated agent instruction files
๐Ÿ”ฎ Metacommand-creatorCreate Claude Code slash commands
๐Ÿ”ฎ Metaplugin-forgeBuild Claude Code plugins & manifests
๐Ÿ”ฎ Metaskill-judgeEvaluate skill design quality
๐Ÿ“ Documentationbackend-to-frontend-handoff-docsAPI handoff docs for frontend
๐Ÿ“ Documentationc4-architectureC4 architecture diagrams with Mermaid
๐Ÿ“ Documentationcrafting-effective-readmesWrite effective README files
๐Ÿ“ Documentationdraw-ioCreate & edit draw.io diagrams
๐Ÿ“ DocumentationexcalidrawWork with Excalidraw diagrams
๐Ÿ“ Documentationfrontend-to-backend-requirementsDocument API requirements
๐Ÿ“ Documentationmarp-slideProfessional presentation slides
๐Ÿ“ Documentationmermaid-diagramsSoftware diagrams with Mermaid
๐Ÿ“ Documentationwriting-clearly-and-conciselyClear, professional writing
๐ŸŽจ Design & Frontenddesign-system-starterCreate design systems
๐ŸŽจ Design & FrontendmuiMaterial-UI v7 patterns
๐ŸŽจ Design & Frontendopenapi-to-typescriptConvert OpenAPI to TypeScript
๐ŸŽจ Design & Frontendreact-devType-safe React 18-19 with TypeScript
๐ŸŽจ Design & Frontendreact-useeffectReact useEffect best practices
๐Ÿ› ๏ธ Developmentdatabase-schema-designerDesign robust database schemas
๐Ÿ› ๏ธ Developmentdependency-updaterSmart dependency management
๐Ÿ› ๏ธ Developmentnaming-analyzerSuggest better variable/function names
๐Ÿ› ๏ธ Developmentlesson-learnedExtract SE lessons from recent code changes
๐Ÿ› ๏ธ Developmentreducing-entropyMinimize codebase size
๐Ÿ› ๏ธ Developmentsession-handoffSeamless AI session transfers
๐ŸŽฏ Planninggame-changing-featuresFind 10x product opportunities
๐ŸŽฏ PlanninggepettoDetailed implementation planning
๐ŸŽฏ Planningrequirements-clarityClarify requirements before coding
๐ŸŽฏ Planningship-learn-nextTurn learning into actionable reps
๐Ÿ‘” Professionaldaily-meeting-updateInteractive daily standup generator
๐Ÿ‘” Professionaldifficult-workplace-conversationsNavigate difficult conversations
๐Ÿ‘” Professionalfeedback-masteryDeliver constructive feedback
๐Ÿ‘” Professionalprofessional-communicationTechnical communication guide
๐Ÿงช Testingqa-test-plannerComprehensive QA test planning
๐Ÿ“ฆ Gitcommit-workHigh-quality git commits
๐Ÿ”ง Utilitiesdatadog-cliDebug with Datadog logs & metrics
๐Ÿ”ง Utilitiesdomain-name-brainstormerGenerate & check domain names
๐Ÿ”ง UtilitieshumanizerRemove AI writing patterns
๐Ÿ”ง Utilitiesmeme-factoryGenerate memes with API
๐Ÿ”ง UtilitiesjiraNatural language Jira interaction
๐Ÿ”ง Utilitiesweb-to-markdownConvert webpages to Markdown

๐Ÿค– Agents & Commands

Requires Claude Code CLI โ€” These agents and commands are exclusive to Claude Code users.

For full access, add the marketplace and install plugins:

/plugin marketplace add softaworks/agent-toolkit
/plugin install codex@agent-toolkit

Agents

Specialized sub-agents that Claude Code can delegate tasks to:

AgentDescription
ascii-ui-mockup-generatorVisualize UI concepts through ASCII mockups
codebase-pattern-finderFind similar implementations and patterns
communication-excellence-coachEmail refinement, tone calibration, roleplay
general-purposeDefault agent for complex multi-step tasks
mermaid-diagram-specialistCreate flowcharts, sequence diagrams, ERDs
ui-ux-designerResearch-backed UI/UX design feedback

Slash Commands

Reusable workflows invoked with /command-name:

CommandDescription
/codex-planCreate implementation plans using Codex 5.2
/compose-emailDraft professional emails
/explain-changes-mental-modelBuild mental model of code changes
/explain-pr-changesGenerate PR summaries
/sync-branchSync feature branch with main
/sync-skills-readmeUpdate README skills table
/viral-tweetOptimize tweet ideas for X engagement

๐Ÿ“– Skill Structure

Each skill contains:

  • SKILL.md - Detailed instructions for the agent (with YAML frontmatter)
  • README.md - User-friendly documentation with examples
  • scripts/ - Helper scripts for automation (optional)
  • references/ - Supporting documentation (optional)

๐Ÿค Contributing

Contributions are welcome! When adding new skills:

  1. Follow the Agent Skills format
  2. Include both SKILL.md (for agents) and README.md (for users)
  3. Add YAML frontmatter to SKILL.md with name: and description: fields
  4. Update this README.md with a link to your skill

๐Ÿ“„ License

MIT


๐Ÿ”— Links

Details

Marketplace
softaworks/agent-toolkit
Source
dist/plugins/openapi-to-typescript
Category
Design Frontend
Keywords
design, frontend, openapi, typescript, api
Listed since
Apr 6, 2026

More from softaworks/agent-toolkit

All 56

Similar to openapi-to-typescript

More Developer Tools