{"_id":"@aircan/swapper","_rev":"3-d193b45045783bb1b81a5cbbe766095c","name":"@aircan/swapper","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@aircan/swapper","version":"1.0.0","keywords":[],"author":{"name":"Haolin"},"license":"ISC","_id":"@aircan/swapper@1.0.0","maintainers":[{"name":"aircan","email":"haolinhom@gmail.com"}],"bin":{"swapper":"bin/swapper.js"},"dist":{"shasum":"4a78bcc18507794caa62ae45bd0e6f2dfff54f05","tarball":"https://registry.npmjs.org/@aircan/swapper/-/swapper-1.0.0.tgz","fileCount":11,"integrity":"sha512-yiUrvouIY6xeVwBum1hsGtNKWT7IgiTKqa9QjEQ2XB9PbmAiJDL8s/zao35USigILJ2WSCJLSXy4SHj7doU7jA==","signatures":[{"sig":"MEQCICa/BdtiiGC79laKk4rNOpel07AZh0eT+SatYIPsAF9PAiBJJZneo8E//KdubnggArD6mKwsRqsacnyZMDjKzcdoSw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43485},"main":"src/index.js","type":"module","engines":{"node":">=18"},"gitHead":"66f19c5eaaefb236466ed3701ef62c9b8aefaa06","scripts":{"start":"node bin/swapper.js"},"_npmUser":{"name":"aircan","email":"haolinhom@gmail.com"},"_npmVersion":"10.9.2","description":"A CLI tool for generating TypeScript API functions and type definitions from Swagger/OpenAPI documents.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"prettier":"^3.2.0","commander":"^12.0.0"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.12.4","_npmOperationalInternal":{"tmp":"tmp/swapper_1.0.0_1776073743850_0.6468047947794968","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aircan/swapper","version":"1.0.1","keywords":[],"author":{"name":"Haolin"},"license":"ISC","_id":"@aircan/swapper@1.0.1","maintainers":[{"name":"aircan","email":"haolinhom@gmail.com"}],"bin":{"swapper":"bin/swapper.js"},"dist":{"shasum":"53fc0d33f0b39cbab6d9bba670215c1af33e7bad","tarball":"https://registry.npmjs.org/@aircan/swapper/-/swapper-1.0.1.tgz","fileCount":11,"integrity":"sha512-VSd5E0mox6xBgLsbwlSZfzWVhj1/iAN1E47wyvk1ONftvee8xOsSQVWT4v4lWeN8fNR/6aaB2bCO0aPa/rhUAw==","signatures":[{"sig":"MEQCIAOF3H//I58+L0BVVJmoGpTMEWXvA3sG3cXeT/wa8d94AiAlJIpiiTN8ZapbC0qLaOkaAeIBNnMA6KL4m/uwzZMqog==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44557},"main":"src/index.js","type":"module","engines":{"node":">=18"},"gitHead":"eb203cc6e958d835036af9b4ddbcb08e0aee4817","scripts":{"start":"node bin/swapper.js"},"_npmUser":{"name":"aircan","email":"haolinhom@gmail.com"},"_npmVersion":"10.9.2","description":"A CLI tool for generating TypeScript API functions and type definitions from Swagger/OpenAPI documents.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"prettier":"^3.2.0","commander":"^12.0.0"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.12.4","_npmOperationalInternal":{"tmp":"tmp/swapper_1.0.1_1776323140092_0.7473001518902047","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@aircan/swapper","version":"1.0.2","description":"A CLI tool for generating TypeScript API functions and type definitions from Swagger/OpenAPI documents.","type":"module","main":"src/index.js","bin":{"swapper":"bin/swapper.js"},"engines":{"node":">=18"},"scripts":{"start":"node bin/swapper.js"},"keywords":[],"author":{"name":"Haolin"},"license":"ISC","packageManager":"pnpm@10.12.4","dependencies":{"commander":"^12.0.0","prettier":"^3.2.0"},"_id":"@aircan/swapper@1.0.2","gitHead":"50e426ee297d134cead3f8f84e19d09f4dd78d48","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-BKDTnIHybyfws/H/jlu0F5hCONKz2AMnqHKGmCLQDK4if7+lP0mJEMBUHu9RU7bL82uPfbFBXJm3hC1DDkBMZg==","shasum":"3f41a097e08bf1c27c0f9bbe8c42e0d77533a663","tarball":"https://registry.npmjs.org/@aircan/swapper/-/swapper-1.0.2.tgz","fileCount":11,"unpackedSize":49588,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFf18UjLxiShGqGr/pvDFSxo+XoC25JRtKTO69PnOp5+AiEA4HP7jg4wY38iwxaGs1XAZBYQHYQpv4o/UyE9jKIXTsY="}]},"_npmUser":{"name":"aircan","email":"haolinhom@gmail.com"},"directories":{},"maintainers":[{"name":"aircan","email":"haolinhom@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/swapper_1.0.2_1777002736654_0.656028357658341"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-13T09:49:03.760Z","modified":"2026-04-24T03:52:16.906Z","1.0.0":"2026-04-13T09:49:04.003Z","1.0.1":"2026-04-16T07:05:40.235Z","1.0.2":"2026-04-24T03:52:16.790Z"},"author":{"name":"Haolin"},"license":"ISC","keywords":[],"description":"A CLI tool for generating TypeScript API functions and type definitions from Swagger/OpenAPI documents.","maintainers":[{"name":"aircan","email":"haolinhom@gmail.com"}],"readme":"# swapper\n\nA CLI tool for generating TypeScript API functions and type definitions from Swagger/OpenAPI documents.\n\nBy default, the generated output is written into two files inside the target directory:\n\n- `types.ts`: type definitions\n- `index.ts`: API request functions\n\n## Requirements\n\n- Node.js `>= 18`\n\n## Installation\n\nFor local development:\n\n```bash\npnpm install\n\npnpm link\n```\n\nInstall it globally with:\n\n```bash\nnpm install -g @aircan/swapper\n```\n\nThen run the CLI with:\n\n```bash\nswapper --help\n```\n\nYou can also run the published package directly with:\n\n```bash\nnpx @aircan/swapper --help\n```\n\nInstall the built-in skill for Codex or Claude Code:\n\n```bash\nswapper install-skill\n```\n\nThe command opens an interactive selector so you can choose Codex or Claude Code with arrow keys.\n\nWhen the skill is used by an agent, the expected execution path is to try the globally installed `swapper` command first. If availability is unclear, verify with `swapper --help` before falling back to a repo-local entrypoint.\n\n## Usage\n\n```bash\nswapper -u <swagger-url> -t <tags> -d <output-dir> -r <request-import> [options]\n```\n\nAn explicit subcommand form is also supported:\n\n```bash\nswapper generate -u <swagger-url> -t <tags> -d <output-dir> -r <request-import> [options]\n```\n\n### Basic Examples\n\nGenerate by controller:\n\n```bash\nswapper \\\n  -u https://swagger-page.com/promotion/api/v2/api-docs \\\n  --tag activity \\\n  --dir ./api \\\n  --prefix /promotion/api \\\n  -r \"import request from '@/utils/request';\"\n```\n\nGenerate specific endpoints:\n\n```bash\nswapper \\\n  -u https://swagger-page.com/promotion/api/v2/api-docs \\\n  --tag GET-/calcProcessConfig,POST-/calcProcessConfig \\\n  --dir ./api \\\n  --prefix /promotion/api \\\n  -r \"import request from '@/utils/request';\"\n```\n\nGenerate a mixed selection:\n\n```bash\nswapper \\\n  -u https://petstore.swagger.io/v2/swagger.json \\\n  --tag DyLkProductMapping,POST-/dyLkProductMapping \\\n  --dir ./src/services \\\n  -r \"import { request } from 'umi';\"\n```\n\n## Options\n\n| Option | Short | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `--url` | `-u` | Yes | None | Swagger document URL |\n| `--tag` | `-t` | Yes | None | Interfaces to generate. Supports controller names or `METHOD-/path`, separated by commas |\n| `--dir` | `-d` | Yes | None | Output directory |\n| `--request` | `-r` | Yes | None | Import statement for the request function |\n| `--out-type` |  | No | `ts` | Output file type. Currently supports `ts` and `js` |\n| `--prefix` | `-p` | No | None | Prefix appended to generated request URLs |\n| `--force` |  | No | `false` | Fully overwrite output files instead of incremental merge |\n\n## Install the Skill\n\nInstall the bundled `generate-swagger-types` skill into Codex or Claude Code on the current machine:\n\n```bash\nswapper install-skill\n```\n\nThe command opens an interactive selector for Codex or Claude Code. If you choose Codex, it installs to:\n\n```text\n${CODEX_HOME:-~/.codex}/skills/generate-swagger-types\n```\n\nIf you choose Claude Code, it installs to:\n\n```text\n${CLAUDE_CONFIG_DIR:-~/.claude}/skills/generate-swagger-types\n```\n\nTo skip the prompt, pass `--agent`:\n\n```bash\nswapper install-skill --agent claude-code\n```\n\nOptional flags:\n\n| Option | Required | Default | Description |\n| --- | --- | --- | --- |\n| `--agent` | No | Interactive selector in TTY; `codex` in non-interactive shells | Target agent. Supports `codex`, `claude-code`, and `claude` |\n| `--dest` | No | Depends on `--agent` | Custom skill installation root |\n| `--force` | No | `true` | Overwrite the destination if the skill already exists |\n| `--no-force` | No | `false` | Fail when the destination skill already exists |\n\nExamples:\n\n```bash\nswapper install-skill --dest ~/.codex/skills\nswapper install-skill --agent claude-code\nswapper install-skill --no-force\n```\n\nRestart Codex or Claude Code after installation so the new skill can be loaded.\n\n## Generation Behavior\n\nIncremental merge is the default mode:\n\n- Existing `types.ts` and `index.ts` files are read first\n- Newly generated types are merged into `types.ts`\n- Newly generated functions are merged into `index.ts`\n- Existing types and functions with the same name are replaced by the latest generated versions\n\nWhen `--force` is used:\n\n- `types.ts` and `index.ts` in the target directory are overwritten directly\n\n## Output Example\n\nRunning:\n\n```bash\nswapper \\\n  -u https://swagger-page.com/promotion/api/v2/api-docs \\\n  --tag activity \\\n  --dir ./api \\\n  --prefix /promotion/api \\\n  -r \"import request from '@/utils/request';\"\n```\n\nwill generate:\n\n```text\napi/\n├── index.ts\n└── types.ts\n```\n\nWhere:\n\n- `types.ts` contains response, request body, and query parameter type definitions\n- `index.ts` contains request functions and `import type` statements\n\n## Development\n\nShow help:\n\n```bash\nnode bin/swapper.js --help\n```\n\nRun directly:\n\n```bash\nnode bin/swapper.js \\\n  -u https://swagger-page.com/promotion/api/v2/api-docs \\\n  --tag activity \\\n  --dir ./api \\\n  --prefix /promotion/api \\\n  -r \"import request from '@/utils/request';\"\n```\n","readmeFilename":"README.md"}