AgentHubAgentHub

Openapi To Typescript @softaworks

claudesonnetSkill

Converts OpenAPI 3.0 JSON/YAML to TypeScript interfaces and type guards. This skill should be used when the user asks to generate types from OpenAPI, convert schema to TS, create API interfaces, or generate TypeScript types from an API specification.

specialistcommunityImplementVerify

Install

curl -o ~/.claude/skills/openapi-to-typescript/SKILL.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/skills/openapi-to-typescript/SKILL.md

Description

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:

If invalid, report the error and stop.

Type Mapping

Primitives

| OpenAPI | TypeScript | |-------------|--------------| | string | string | | number | number | | integer | number | | boolean | boolean | | null | null |

Format Modifiers

| Format | TypeScript | |---------------|-------------------------| | uuid | string (comment UUID) | | date | string (comment date) | | date-time | string (comment ISO) | | email | string (comment email)| | uri | string (comment URI) |

Complex Types

Object:

Array:

Enum:

oneOf (Union):

allOf (Intersection/Extends):

Code Generation

File Header

Interfaces (from components/schemas)

For each schema in components/schemas:

  • Use OpenAPI description as JSDoc
  • Fields in required[] have no ?
  • Fields outside required[] have ?

Request/Response Types (from paths)

For each endpoint in paths:

Naming convention:

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

Type Guards

For each main interface, generate a type guard:

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)

$ref Resolution

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

  1. Extract the schema name (Product)
  2. Use the type directly (don't resolve inline)

Complete Example

Input (OpenAPI):

Output (TypeScript):

Common Errors

| Error | Action | |-------|--------| | OpenAPI version != 3.0.x | Report that only 3.0 is supported | | $ref not found | List missing refs | | Unknown type | Use unknown and warn | | Circular reference | Use type alias with lazy reference |

Capabilities

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

Tools

types/api.tsdate-time

Related Items

From the same repository — designed to work together

Install Allcurl -o ~/.claude/skills/openapi-to-typescript/SKILL.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/skills/openapi-to-typescript/SKILL.md && curl -o ~/.claude/agents/ascii-ui-mockup-generator.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/ascii-ui-mockup-generator.md && curl -o ~/.claude/agents/codebase-pattern-finder.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/codebase-pattern-finder.md && curl -o ~/.claude/agents/general-purpose.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/general-purpose.md && curl -o ~/.claude/agents/ui-ux-designer.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/ui-ux-designer.md && curl -o ~/.claude/agents/mermaid-diagram-specialist.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/mermaid-diagram-specialist.md && curl -o ~/.claude/agents/communication-excellence-coach.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/communication-excellence-coach.md

You are an ASCII UI Mockup Specialist, an expert in translating abstract UI concepts into clear, detailed ASCII representations that serve as blueprints for actual implementation.

claudesonnet
AnalystImplementPlanworks-with:explore
1,891 170
curl -o ~/.claude/agents/ascii-ui-mockup-generator.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/ascii-ui-mockup-generator.md

codebase-pattern-finder is a useful subagent_type for finding similar implementations, usage examples, or existing patterns that can be modeled after. It will give you concrete code examples based on what you're looking for! It's sorta like codebase-locator, but it will not only tell you the locatio

claudesonnet
WorkerDiscoverworks-with:criticworks-with:librarian
1,891 170
curl -o ~/.claude/agents/codebase-pattern-finder.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/codebase-pattern-finder.md

Default agent for handling complex, multi-step tasks with automatic delegation capabilities

claudesonnet
SpecialistPlanVerify
1,891 170
curl -o ~/.claude/agents/general-purpose.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/general-purpose.md

Expert UI/UX design critic and advisor who provides research-backed, opinionated feedback on interfaces. Use when you need honest assessment of design decisions, want to avoid generic "AI slop" aesthetics, need evidence-based UX guidance, or want distinctive design direction grounded in actual user

claudeopus
AnalystPlanReviewworks-with:criticworks-with:designer
1,891 170
curl -o ~/.claude/agents/ui-ux-designer.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/ui-ux-designer.md

Mermaid diagram specialist for creating flowcharts, sequence diagrams, ERDs, and architecture visualizations

claudesonnet
WorkerPlanImplementworks-with:architectworks-with:writer
1,891 170
curl -o ~/.claude/agents/mermaid-diagram-specialist.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/mermaid-diagram-specialist.md

PROACTIVELY use when reviewing communication drafts or preparing difficult conversations. Provides email refinement, tone calibration, roleplay practice, and presentation feedback with actionable suggestions.

claudeopus
AnalystReviewPlanworks-with:criticworks-with:architect
1,891 170
curl -o ~/.claude/agents/communication-excellence-coach.md https://raw.githubusercontent.com/softaworks/agent-toolkit/main/agents/communication-excellence-coach.md