| name | generate-models |
| description | Generate TypeScript interfaces and enums from OpenAPI schemas using aptx-ft CLI. Use when user asks to: (1) generate types/models from OpenAPI/Swagger, (2) create TypeScript interfaces from API schema, (3) extract type definitions from openapi.json, (4) generate selective models with --name filter, (5) preserve translated enum values, (6) track generated files with manifest, (7) preview changes before generation, or (8) update barrel files automatically. Do NOT use for full artifact generation with request layer or Material UI enum adaptation. |
Generate TypeScript Models
Generate TypeScript interfaces/enums from OpenAPI via aptx-ft.
Prerequisites
pnpm add -D @aptx/frontend-tk-cli
Discovery Phase - MANDATORY FIRST STEP
Before executing any generation command, you MUST discover the actual project configuration.
For Monorepo Projects
-
Find packages directory:
ls -d packages/*/
-
Identify model package and get its name:
cat packages/domains/package.json 2>/dev/null || cat packages/models/package.json 2>/dev/null
Extract the "name" field - this is your --model-path value.
Critical Rules
| ā NEVER Do This | ā
ALWAYS Do This |
|---|
| Guess package name from project directory | Read package.json to get actual "name" |
Assume @project-name/models | Use the exact value from "name" field |
Infer from packages/domains/ path | Package name ā directory name |
Example Discovery
$ cat packages/domains/package.json
{ "name": "@repo/domains", ... } ā Package name is @repo/domains
Workflow
- Discovery ā Read
package.json files to get actual package names
- Identify project type ā recommend parameters
- Check output directory ā determine if
--preserve is needed
- Confirm with user ā output dir, style, filters
- Execute ā show command, get approval, run
Preserve Parameter Logic
ALWAYS check if target directory contains existing models before generating:
ls ./src/models/*.ts 2>/dev/null || echo "empty"
| Directory State | Action |
|---|
| Empty or not exists | Generate WITHOUT --preserve |
| Has existing .ts files | Generate WITH --preserve to keep enum translations |
Why: When regenerating models in a non-empty directory, --preserve keeps manually translated enum names while adding new values. Only skip --preserve for fresh generation.
Project Types
| Type | Output | Command |
|---|
| Single project | ./src/models | pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --style module |
| Monorepo | ./packages/models/src | pnpm exec aptx-ft -i ./openapi.json model gen --output ./packages/models/src --style module |
Key Options
| Option | Purpose |
|---|
--style module | ES modules, individual exports (default, recommended) |
--style declaration | Single declaration file (legacy compatibility) |
--name <Schema> | Generate only specified models (repeatable) |
--preserve | Keep manually translated enum names on regeneration |
Manifest Tracking
The CLI automatically tracks generated files and detects changes between generations.
Manifest CLI Options
| Option | Default | Purpose |
|---|
--no-manifest | false | Disable manifest tracking |
--manifest-dir <path> | .generated | Custom manifest directory |
--dry-run | false | Preview mode: generate report without updating manifest |
Generated Manifest Files
When manifest tracking is enabled (default), the following files are generated:
<output>/
āāā .generated/
ā āāā manifest.json # Tracks all generated files
ā āāā deletion-report.json # Machine-readable change report
ā āāā deletion-report.md # Human-readable change report with LLM suggestions
āāā models...
Manifest Report Contents
The deletion-report.md includes:
- Summary table: Added/deleted/unchanged file counts
- Deleted files: List of files removed since last generation
- Added files: List of new files added
- LLM suggestions: Follow-up actions for handling deleted files
When to Use Manifest Options
| Scenario | Command |
|---|
| Normal generation | Omit manifest options (default) |
| CI/CD without tracking | Add --no-manifest |
| Preview changes before applying | Add --dry-run |
| Custom manifest location | Add --manifest-dir ./meta |
Automatic Barrel Updates
The CLI automatically updates barrel files (index.ts) after generation.
You no longer need to manually run barrel gen after generating models - the model gen command handles this automatically.
What Gets Updated
<output>/index.ts - Barrel file for the models directory
When Manual Barrel Update is Needed
The automatic update handles most cases. Use manual barrel gen only when:
- Fixing corrupted barrel files
- Processing non-standard directory structures
- One-time batch updates across multiple directories
Preserve Workflow
Preserve Workflow
Recommended when regenerating models after API updates. Keeps manually translated enum names while adding new values.
- Generate models
- Manually translate enums (e.g.,
Value1 ā Success)
- API updates with new enum values
- Regenerate with
--preserve ā keeps translations, adds new values
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --preserve
Quick Reference
ls ./src/models/*.ts 2>/dev/null
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --preserve
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --style declaration
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --name User --name Role
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --dry-run
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --no-manifest
pnpm exec aptx-ft -i ./openapi.json model gen --output ./src/models --manifest-dir ./meta
npx aptx-ft -i ./openapi.json model gen --output ./src/models
Output
TypeScript model files (interface/enum). Does not include request layer code.
Boundaries
This skill generates TypeScript models only:
- Does NOT generate request layer code (functions, hooks) ā use
generate-artifacts
- Does NOT adapt Materal-specific enum semantics ā use
adapt-materal-enums
- Does NOT validate OpenAPI specification correctness
- Only supports JSON format (not YAML)
Related Skills
- generate-artifacts: Full generation (models + request layer)
- adapt-materal-enums: Materal framework enum adaptation
- download-openapi: Fetch OpenAPI spec from URL