openapi-typescript

Generate TypeScript types and clients from OpenAPI 3.x and Swagger 2.0 specifications.

1|Updated Mar 1, 2026
One-click install
npx skills add https://github.com/hjemmesidekongen/ai --skill openapi-typescript
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openapi-typescript
Source: https://github.com/hjemmesidekongen/ai/tree/main/plugins/smedjen/skills/openapi-typescript
Command: npx skills add https://github.com/hjemmesidekongen/ai --skill openapi-typescript

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill ensures your API clients and server code are always in sync with your OpenAPI specification, preventing runtime errors and improving developer confidence.

Core Features & Use Cases

  • Type Generation: Automatically generate TypeScript types from OpenAPI 3.x or Swagger 2.0 specs.
  • Type-Safe Clients: Use openapi-fetch to create clients that infer request/response types directly from generated schemas.
  • Runtime Validation: Integrate with Zod or TypeBox to validate API responses at runtime, bridging the gap between compile-time and runtime safety.
  • Use Case: Automatically generate all frontend API types from your backend's OpenAPI spec, ensuring that UI components consuming the API always have accurate type information, and catch breaking changes in CI.

Quick Start

Use the openapi-typescript skill to generate type definitions from the 'openapi.yaml' file in the current directory.

Frequently Asked Questions about openapi-typescript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate TypeScript types from an OpenAPI specification?

You can generate TypeScript types from an OpenAPI specification by parsing OpenAPI 3.x or Swagger 2.0 schemas to automatically produce type definitions. This ensures your frontend API types accurately match your backend contract.

What is the best way to prevent API contract drift in a TypeScript frontend?

The best way to prevent API contract drift is to automatically generate type-safe API clients from your OpenAPI spec. This ensures your client and server code remain in sync, preventing runtime errors caused by breaking API changes.

Can I use openapi-fetch to create a type-safe API client?

Yes, you can use openapi-fetch to create a type-safe API client that infers request and response types directly from your generated OpenAPI schemas. This approach eliminates manual typing errors and ensures compile-time contract adherence.

Does generating types from OpenAPI support runtime validation?

Generating types from OpenAPI supports runtime validation by integrating with tools like Zod or TypeBox. This bridges the gap between compile-time type safety and runtime validation, allowing you to validate API responses dynamically.

Does OpenAPI type generation work with Swagger 2.0 specifications?

OpenAPI type generation does work with Swagger 2.0 specifications alongside OpenAPI 3.x. It parses your existing Swagger 2.0 schemas to automatically generate accurate TypeScript type definitions and clients for your legacy APIs.