davila7 avatar

Openapi To Typescript

This converts OpenAPI 3.0 specs into TypeScript interfaces and runtime type guards. It reads your JSON or YAML spec, pulls out schemas and endpoint definitions, then generates properly typed interfaces with optional fields marked correctly, plus type guard functions for runtime validation. The output includes request and response types for each endpoint, handles refs and complex types like oneOf and allOf, and adds JSDoc comments from your spec descriptions. Saves you from manually writing types and keeps them in sync with your API contract. The type guards are especially handy since TypeScript's types disappear at runtime but you still need to validate API responses.

skills.sh installs
211
GitHub stars
33.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add davila7/claude-code-templates --skill openapi-to-typescript --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/davila7/claude-code-templates
Category
Backend & APIs
First seen
Jun 3, 2026

More from davila7/claude-code-templates

All 618
1manojbajaj95 avatarcrm-integrationmanojbajaj95/claude-gtm-pluginCRM integration patterns for Close CRM, HubSpot, and Salesforce. Use when: Close CRM, HubSpot, Salesforce, CRM API, lead sync, deal sync, activity logging, CRM 210skills.sh installs
2personamanagmentlayer avatarspring-boot-expertpersonamanagmentlayer/pclExpert-level Spring Boot, Spring Framework, REST APIs, and microservices development209skills.sh installs
3davila7 avatarlabarchive-integrationdavila7/claude-code-templatesElectronic lab notebook API integration. Access notebooks, manage entries/attachments, backup notebooks, integrate with Protocols.io/Jupyter/REDCap, for program208skills.sh installs
4tuziapi avatartuzi-image-gentuziapi/tuzi-skills通过兔子API(nano-banana 模型)、Google、OpenAI、DashScope 和 Replicate 进行 AI 图片生成。支持文生图、参考图片、宽高比、模型选择,以及 OpenAI 兼容网关方言切换。当用户要求生成、创建或绘制图片时使用。208skills.sh installs
5databricks avatardatabricksdatabricks/databricks-agent-skillsDatabricks CLI operations: auth, profiles, data exploration, and bundles. Contains up-to-date guidelines for Databricks-related CLI tasks.205skills.sh installs
6harperaa avatarsecurity-headersharperaa/secure-claude-skillsConfigure security headers to defend against clickjacking, XSS, MIME confusion, and SSL stripping attacks. Use this skill when you need to set up Content-Securi203skills.sh installs