Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apigen is a standalone npm CLI that reads OpenAPI 3.0+ and Swagger 2.0 specs and
## Commands

```bash
bun test # run tests (31 tests across 10 files)
bun test # run tests (56 tests across 11 files)
bun run typecheck # tsc --noEmit
bun run build # compile to dist/
```
Expand All @@ -32,6 +32,7 @@ src/
├── index.ts # Public exports (config only)
├── loader.ts # Reads YAML/JSON, converts Swagger 2→3, bundles refs
├── ir.ts # Extracts IR (operations + schemas) from OpenAPI spec
├── discover.ts # Auto-discovers API specs at well-known paths
├── writer.ts # Orchestrates all generators, writes to disk
├── generators/
│ ├── types.ts # IR → TypeScript interfaces
Expand Down
70 changes: 66 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ apigen generate -i ./openapi.yaml

| Flag | Required | Default | Description |
|--------------------------|----------|-------------------------|------------------------------------------------------|
| `-i, --input <path>` | Yes | -- | Path to the OpenAPI or Swagger spec file. |
| `-i, --input <path>` | No | *(interactive prompt)* | Path or URL to the OpenAPI or Swagger spec file. When omitted, shows an interactive prompt. |
| `-o, --output <path>` | No | `./src/api/generated` | Output directory for generated files. |
| `--no-mock` | No | (mock enabled) | Skip mock data generation. |
| `--split` | No | (disabled) | Split output into per-tag feature folders. |

> **Interactive mode:** When `-i` is omitted, apigen prompts you to choose between providing a local file path, a direct URL, or auto-discovering a spec from a base URL (tries well-known paths like `/v3/api-docs`, `/swagger.json`, `/openapi.json`).

**Examples**

Expand All @@ -116,6 +119,8 @@ apigen generate -i ./spec.json -o ./src/generated --no-mock
| `test-mode-provider.tsx` | React context provider to switch hooks to mock mode. |
| `index.ts` | Barrel file re-exporting all generated modules. |

> When `--no-mock` is used, `mocks.ts` and `test-mode-provider.tsx` are not generated. When `--split` is used, output is organized into per-tag subdirectories.

---

## Internal modules
Expand All @@ -125,6 +130,7 @@ The following modules are implementation details and are **not** part of the pub
- **loader** (`src/loader.ts`) -- reads and normalizes OpenAPI/Swagger specs.
- **ir** (`src/ir.ts`) -- extracts an intermediate representation from a parsed spec.
- **generators** (`src/generators/`) -- emit TypeScript source strings from the IR.
- **discover** (`src/discover.ts`) -- auto-discovers API specs at well-known paths.
- **writer** (`src/writer.ts`) -- writes generator output to disk.

These may change without notice between versions. Import only from the package entrypoint (`apigen`).
Loading