openapi-to-typescript

Generate TypeScript interfaces and type guards from OpenAPI 3.0 specifications.

Updated Jan 23, 2024
One-click install
npx skills add https://github.com/TeamMagicOfConch/conch --skill openapi-to-typescript-teammagicofconch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openapi-to-typescript
Source: https://github.com/TeamMagicOfConch/conch/tree/main/.agents/skills/openapi-to-typescript
Command: npx skills add https://github.com/TeamMagicOfConch/conch --skill openapi-to-typescript-teammagicofconch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

OpenAPI specifications often require manual translation into TypeScript interfaces and safety guards; this skill automates the conversion to ensure strongly-typed API clients.

Core Features & Use Cases

  • Generate TypeScript interfaces from components.schemas
  • Create robust type guards from OpenAPI definitions
  • Resolve $ref references across schemas and paths to produce cohesive types
  • Output typed definitions to a single file (e.g., types/api.ts) for easy integration

Quick Start

Provide the OpenAPI file path to generate TypeScript types for your API.

Frequently Asked Questions about openapi-to-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?

To generate TypeScript types from an OpenAPI specification, provide the file path to automatically convert components.schemas and paths into strongly-typed interfaces and type guards. The tool resolves $ref references and outputs a cohesive typed definitions file.

Can I create type guards from OpenAPI 3.0 definitions?

Yes, you can create type guards from OpenAPI 3.0 definitions automatically. The conversion process reads your API specification and generates robust type guards alongside TypeScript interfaces to ensure strongly-typed API validation workflows.

Does the TypeScript codegen support both JSON and YAML OpenAPI documents?

Yes, TypeScript codegen supports both JSON and YAML OpenAPI documents. The automated conversion applies to API design, client generation, and validation workflows across both formats to produce cohesive typed definitions.

How are $ref references resolved when converting OpenAPI to TypeScript?

When converting OpenAPI to TypeScript, $ref references are resolved across schemas and paths to produce cohesive types. This ensures that all linked definitions in your API specification are accurately translated into a single strongly-typed file.

What is the best way to automate type safety for an API client?

The best way to automate type safety for an API client is to generate TypeScript interfaces and type guards from your OpenAPI spec. This removes manual translation errors and outputs a typed definitions file for easy integration.

Where are the generated TypeScript interfaces and type guards output?

The generated TypeScript interfaces and type guards are output to a single strongly-typed file, such as types/api.ts. This consolidated output file contains all definitions resolved from your OpenAPI components and paths for easy integration.