openapi-codegen skill
다양한 도구를 사용하여 OpenAPI 명세로부터 타입 안정성이 보장된 API 클라이언트와 TypeScript 타입을 생성합니다.
- GitHub 스타
- 47
- 파일
- 5
- 마지막 커밋
- 2026년 11월 9일
- 라이선스
- MIT
- 허용된 도구
- 6
openapi-codegen skill은 무엇을 하나요?
openapi-codegen은(는) agent skill입니다. 다양한 도구를 사용하여 OpenAPI 명세로부터 타입 안정성이 보장된 API 클라이언트와 TypeScript 타입을 생성합니다.
skill의 SKILL.md에서 생성된 요약입니다.
openapi-codegen skill 정보
OpenAPI 명세로부터 타입 안정성이 보장된 API 클라이언트와 TypeScript 정의를 생성하는 것이 이 SKILL의 핵심 기능입니다. 런타임 에러를 방지하기 위해 프론트엔드 또는 클라이언트 측 코드를 백엔드 API 계약과 동기화해야 하는 개발자에게 유용합니다. 이 SKILL은 가벼운 타입 생성을 위한 openapi-typescript, fetch 또는 axios 기반의 전체 클라이언트 생성을 위한 openapi-generator-cli, 그리고 커스텀 템플릿 기반 생성을 위한 swagger-typescript-api 등 여러 전문 도구를 제공합니다.
사용자가 API 클라이언트 생성, OpenAPI 스키마 기반 타입 생성, 또는 trpc-openapi를 사용한 tRPC 라우터의 OpenAPI 문서 변환을 요청할 때 에이전트는 이 SKILL을 로드해야 합니다. bash 명령어와 파일 시스템 도구를 활용하여 의존성을 설치하고, 생성 스크립트를 실행하며, 결과 코드를 프로젝트 디렉토리에 작성합니다. 이 SKILL은 명세 자체를 만드는 것이 아니라, 기존 명세를 사용 가능한 코드로 변환하는 데 집중한다는 점에서 차별화됩니다.
agent가 수행할 수 있는 작업
- 1TypeScript 타입 생성런타임 오버헤드 없이 OpenAPI YAML 파일로부터 가벼운 TypeScript 정의를 생성합니다.
- 2전체 API 클라이언트 생성OpenAPI 명세를 기반으로 fetch 또는 axios를 사용하는 완전한 API 클라이언트 구현체를 생성합니다.
- 3tRPC를 OpenAPI로 내보내기tRPC 라우터를 OpenAPI 문서로 변환하여 외부 사용자가 API와 상호작용할 수 있도록 합니다.
- 4클라이언트 생성 자동화OpenAPI 명세 파일이 변경될 때마다 API 타입을 자동으로 다시 생성하는 워크플로우를 설정합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
openapi-codegen skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.Claude Code에 openapi-codegen skill 설치
~/.claude/skills/openapi-codegen/SKILL.md
$ npx degit claude-dev-suite/claude-dev-suite/skills/api-integration/openapi-codegen ~/.claude/skills/openapi-codegenClaude Code (project)에 openapi-codegen skill 설치
.claude/skills/openapi-codegen/SKILL.md
$ npx degit claude-dev-suite/claude-dev-suite/skills/api-integration/openapi-codegen .claude/skills/openapi-codegenCodex에 openapi-codegen skill 설치
~/.agents/skills/openapi-codegen/SKILL.md
$ npx degit claude-dev-suite/claude-dev-suite/skills/api-integration/openapi-codegen ~/.agents/skills/openapi-codegenGemini CLI에 openapi-codegen skill 설치
~/.gemini/skills/openapi-codegen/SKILL.md
$ npx degit claude-dev-suite/claude-dev-suite/skills/api-integration/openapi-codegen ~/.gemini/skills/openapi-codegenClaude.ai에 openapi-codegen skill 설치
npx degit claude-dev-suite/claude-dev-suite/skills/api-integration/openapi-codegen openapi-codegen && zip -r openapi-codegen.zip openapi-codegen # claude.ai → Customize → Skills → + → Create skill → Upload a skill → openapi-codegen.zip
자동 검사
2026년 11월 15일에 실행됨전체 보고서 →아직 검증되지 않았습니다. 스킬은 점수 80, 심각한 발견 없음, 검사에 충분한 데이터가 필요합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능claude-dev-suite/claude-dev-suite/skills/api-integration/openapi-codegen is public and reachablegithub.com/claude-dev-suite/claude-dev-suite/tree/HEAD/skill ↗통과
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit 2026-11-09github.com/claude-dev-suite/claude-dev-suite/commits ↗통과
- 스크립트에 다운로드 후 실행이나 자격 증명 탈취가 없음No scripts in the skill folder통과
- SKILL.md에 숨겨진 지침 없음No override phrases, safeguard switches, credential requests or hidden charactersgithub.com/claude-dev-suite/claude-dev-suite/blob/HEAD/skill ↗통과
- 사전 허용 도구가 제한됨Bash lets the agent run any shell command without askinggithub.com/claude-dev-suite/claude-dev-suite/blob/HEAD/skill ↗결함 발견
- SKILL.md가 Agent Skills 형식을 따름Valid name and description; says when to use it; 429 linesgithub.com/claude-dev-suite/claude-dev-suite/blob/HEAD/skill ↗통과
SKILL.md
GitHub에서 보기OpenAPI Code Generation Core Knowledge
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:openapi-codegenfor comprehensive documentation.
openapi-typescript (Types Only)
Generates TypeScript types from OpenAPI schemas. Lightweight, no runtime.
# Installation
npm install -D openapi-typescript
# Generate types
npx openapi-typescript ./openapi.yaml -o ./src/types/api.ts
npx openapi-typescript https://api.example.com/openapi.json -o ./src/types/api.ts
Generated Types Usage
import type { paths, components } from './types/api';
// Schema types
type User = components['schemas']['User'];
type CreateUserDto = components['schemas']['CreateUserDto'];
// Request/Response types
type CreateUserRequest = paths['/users']['post']['requestBody']['content']['application/json'];
type UserResponse = paths['/users/{id}']['get']['responses']['200']['content']['application/json'];
type UsersListResponse = paths['/users']['get']['responses']['200']['content']['application/json'];
// Path parameters
type UserPathParams = paths['/users/{id}']['get']['parameters']['path'];
With openapi-fetch
import createClient from 'openapi-fetch';
import type { paths } from './types/api';
const client = createClient<paths>({
baseUrl: 'https://api.example.com',
});
// Fully typed requests
const { data, error } = await client.GET('/users/{id}', {
params: { path: { id: '123' } },
});
const { data } = await client.POST('/users', {
body: { name: 'John', email: 'john@example.com' },
});
// Query parameters
const { data } = await client.GET('/users', {
params: { query: { status: 'active', page: 1 } },
});
openapi-generator-cli (Full Client)
Generates complete API clients with fetch/axios implementations.
# Installation
npm install -D @openapitools/openapi-generator-cli
# Generate TypeScript Fetch client
npx @openapitools/openapi-generator-cli generate \
-i openapi.yaml \
-g typescript-fetch \
-o ./src/api-client
# Generate TypeScript Axios client
npx @openapitools/openapi-generator-cli generate \
-i openapi.yaml \
-g typescript-axios \
-o ./src/api-client
Configuration File
# openapitools.json
{
"$schema": "https://raw.githubusercontent.com/OpenAPITools/openapi-generator-cli/master/apps/generator-cli/src/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.0.0",
"generators": {
"typescript-client": {
"generatorName": "typescript-fetch",
"output": "#{cwd}/src/api-client",
"inputSpec": "#{cwd}/openapi.yaml",
"additionalProperties": {
"supportsES6": true,
"npmName": "@myorg/api-client",
"typescriptThreePlus": true,
"withInterfaces": true
}
}
}
}
}
Generated Client Usage
import { Configuration, UsersApi } from './api-client';
const config = new Configuration({
basePath: 'https://api.example.com',
accessToken: () => localStorage.getItem('token') || '',
});
const usersApi = new UsersApi(config);
// Typed API calls
const users = await usersApi.listUsers({ status: 'active' });
const user = await usersApi.getUserById({ id: '123' });
const newUser = await usersApi.createUser({
createUserDto: { name: 'John', email: 'john@example.com' },
});
swagger-typescript-api
Fast, customizable generator with template support.
# Installation
npm install -D swagger-typescript-api
# Generate
npx swagger-typescript-api -p ./openapi.yaml -o ./src/api -n api.ts
Configuration
npx swagger-typescript-api \
-p ./openapi.yaml \
-o ./src/api \
-n api.ts \
--axios \ # Use axios instead of fetch
--modular \ # Separate files per tag
--route-types \ # Generate route types
--extract-request-body \ # Extract request body types
--extract-response-body # Extract response body types
Generated Client Usage
import { Api } from './api/api';
const api = new Api({
baseUrl: 'https://api.example.com',
securityWorker: () => ({
headers: { Authorization: `Bearer ${getToken()}` },
}),
});
// Typed API calls
const users = await api.users.usersList({ status: 'active' });
const user = await api.users.usersDetail('123');
const newUser = await api.users.usersCreate({
name: 'John',
email: 'john@example.com',
});
trpc-openapi (Export tRPC as OpenAPI)
Generate OpenAPI spec from tRPC router. Useful for external API consumers.
npm install trpc-openapi
Define OpenAPI Endpoints
import { initTRPC } from '@trpc/server';
import { OpenApiMeta } from 'trpc-openapi';
import { z } from 'zod';
const t = initTRPC.meta<OpenApiMeta>().create();
export const appRouter = t.router({
getUser: t.procedure
.meta({
openapi: {
method: 'GET',
path: '/users/{id}',
tags: ['users'],
summary: 'Get user by ID',
},
})
.input(z.object({ id: z.string() }))
.output(z.object({
id: z.string(),
name: z.string(),
email: z.string(),
}))
.query(({ input }) => getUserById(input.id)),
createUser: t.procedure
.meta({
openapi: {
method: 'POST',
path: '/users',
tags: ['users'],
summary: 'Create a new user',
},
})
.input(z.object({
name: z.string(),
email: z.string().email(),
}))
.output(z.object({
id: z.string(),
name: z.string(),
email: z.string(),
}))
.mutation(({ input }) => createUser(input)),
});
Generate OpenAPI Document
import { generateOpenApiDocument } from 'trpc-openapi';
import { appRouter } from './router';
const openApiDocument = generateOpenApiDocument(appRouter, {
title: 'My API',
version: '1.0.0',
baseUrl: 'https://api.example.com',
});
// Save to file
import fs from 'fs';
fs.writeFileSync('./openapi.json', JSON.stringify(openApiDocument, null, 2));
REST Handler
import { createOpenApiNextHandler } from 'trpc-openapi';
import { appRouter } from './router';
// Next.js API route: pages/api/[...trpc].ts
export default createOpenApiNextHandler({
router: appRouter,
createContext: () => ({}),
});
Production Readiness
CI/CD Integration
# .github/workflows/generate-client.yml
name: Generate API Client
on:
push:
paths:
- 'openapi.yaml'
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Generate types
run: npx openapi-typescript ./openapi.yaml -o ./src/types/api.ts
- name: Check for changes
id: check
run: |
if git diff --quiet src/types/api.ts; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push
if: steps.check.outputs.changed == 'true'
run: |
git config --local user.email "bot@example.com"
git config --local user.name "API Generator Bot"
git add src/types/api.ts
git commit -m "chore: regenerate API types"
git push
Package Scripts
{
"scripts": {
"generate:types": "openapi-typescript ./openapi.yaml -o ./src/types/api.ts",
"generate:client": "openapi-generator-cli generate -c openapitools.json",
"generate:all": "npm run generate:types && npm run generate:client",
"precommit": "npm run generate:types && git add src/types/api.ts"
}
}
Watch Mode Development
# openapi-typescript with watch
npx openapi-typescript ./openapi.yaml -o ./src/types/api.ts --watch
# Or use nodemon
npx nodemon --watch openapi.yaml --exec "npx openapi-typescript ./openapi.yaml -o ./src/types/api.ts"
Validation Before Generation
# Validate spec first
npx @redocly/cli lint openapi.yaml
# Then generate
npx openapi-typescript ./openapi.yaml -o ./src/types/api.ts
Monitoring Metrics
| Metric | Target |
|---|---|
| Generated type coverage | 100% of endpoints |
| Build time with generation | < 30s |
| Type errors after generation | 0 |
| Spec validation errors | 0 |
Checklist
- OpenAPI spec validation in CI
- Automated type generation on spec changes
- Generated code committed or gitignored
- Version pinned for generator CLI
- Custom templates documented
- API client initialization documented
- Error handling patterns documented
- Authentication setup in client
- Breaking change detection
- Generated code tested
When NOT to Use This Skill
- Writing OpenAPI specifications (use
openapiskill) - GraphQL type generation (use
graphql-codegenskill) - tRPC type-safe APIs (use
trpcskill) - Manual API client implementation
- Simple APIs where manual types suffice
Anti-Patterns
| Anti-Pattern | Why It's Bad | Solution |
|---|---|---|
| Committing generated code to git | Merge conflicts, stale code | Add to .gitignore, generate in CI/build |
| Not versioning generator CLI | Inconsistent output | Pin generator versions in package.json |
| Editing generated files manually | Changes lost on regeneration | Extend or wrap generated code |
| No validation before generation | Invalid types generated | Validate spec with @redocly/cli first |
| Using different generators across team | Type inconsistencies | Standardize on one generator |
| Generating from remote spec without caching | Slow builds, network dependency | Cache spec locally or use schema registry |
| Not updating on spec changes | Type/runtime mismatch | Run generation in CI on spec updates |
| Missing error handling in generated code | Poor error UX | Wrap generated client with error handling |
Quick Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| Generation fails | Invalid OpenAPI spec | Validate with @redocly/cli lint |
| Type errors after generation | Spec doesn't match API | Verify spec matches actual responses |
| Missing types | Spec incomplete or refs broken | Check all $refs resolve, add missing schemas |
| Wrong HTTP client generated | Generator config mismatch | Check -g flag or generator setting |
| Circular reference errors | Self-referencing schemas | Use discriminators or flatten schema |
| Slow generation | Large spec file | Use spec splitting or partial generation |
| Auth not working | Security scheme not configured | Add securityWorker or token config |
| "Cannot find module" errors | Generation didn't complete | Check for generation errors, rerun |
| Type conflicts | Multiple generators running | Use single generator, remove others |
Reference Documentation
이 스킬의 파일
5openapi-codegen skill 질문
Claude Code에 openapi-codegen skill을 어떻게 설치하나요?
npx degit claude-dev-suite/claude-dev-suite/skills/api-integration/openapi-codegen ~/.claude/skills/openapi-codegen를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
openapi-codegen skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
이 SKILL은 어떤 도구들을 지원하나요?
openapi-typescript, openapi-generator-cli, swagger-typescript-api, trpc-openapi를 지원합니다.
이것으로 OpenAPI 명세를 작성할 수 있나요?
아니요, 명세 작성에는 'openapi' SKILL을 사용해야 합니다. 이 SKILL은 클라이언트 코드 생성에 특화되어 있습니다.
코드 생성 전에 OpenAPI 명세가 유효한지 어떻게 확인하나요?
@redocly/cli lint 명령어를 사용하여 명세의 유효성을 검사할 수 있습니다.
생성 후 타입 에러가 발생하면 어떻게 해야 하나요?
작성한 명세가 실제 API 응답과 일치하는지 확인하십시오.