npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aircan/swapper

v1.0.2

Published

A CLI tool for generating TypeScript API functions and type definitions from Swagger/OpenAPI documents.

Readme

swapper

A CLI tool for generating TypeScript API functions and type definitions from Swagger/OpenAPI documents.

By default, the generated output is written into two files inside the target directory:

  • types.ts: type definitions
  • index.ts: API request functions

Requirements

  • Node.js >= 18

Installation

For local development:

pnpm install

pnpm link

Install it globally with:

npm install -g @aircan/swapper

Then run the CLI with:

swapper --help

You can also run the published package directly with:

npx @aircan/swapper --help

Install the built-in skill for Codex or Claude Code:

swapper install-skill

The command opens an interactive selector so you can choose Codex or Claude Code with arrow keys.

When 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.

Usage

swapper -u <swagger-url> -t <tags> -d <output-dir> -r <request-import> [options]

An explicit subcommand form is also supported:

swapper generate -u <swagger-url> -t <tags> -d <output-dir> -r <request-import> [options]

Basic Examples

Generate by controller:

swapper \
  -u https://swagger-page.com/promotion/api/v2/api-docs \
  --tag activity \
  --dir ./api \
  --prefix /promotion/api \
  -r "import request from '@/utils/request';"

Generate specific endpoints:

swapper \
  -u https://swagger-page.com/promotion/api/v2/api-docs \
  --tag GET-/calcProcessConfig,POST-/calcProcessConfig \
  --dir ./api \
  --prefix /promotion/api \
  -r "import request from '@/utils/request';"

Generate a mixed selection:

swapper \
  -u https://petstore.swagger.io/v2/swagger.json \
  --tag DyLkProductMapping,POST-/dyLkProductMapping \
  --dir ./src/services \
  -r "import { request } from 'umi';"

Options

| Option | Short | Required | Default | Description | | --- | --- | --- | --- | --- | | --url | -u | Yes | None | Swagger document URL | | --tag | -t | Yes | None | Interfaces to generate. Supports controller names or METHOD-/path, separated by commas | | --dir | -d | Yes | None | Output directory | | --request | -r | Yes | None | Import statement for the request function | | --out-type | | No | ts | Output file type. Currently supports ts and js | | --prefix | -p | No | None | Prefix appended to generated request URLs | | --force | | No | false | Fully overwrite output files instead of incremental merge |

Install the Skill

Install the bundled generate-swagger-types skill into Codex or Claude Code on the current machine:

swapper install-skill

The command opens an interactive selector for Codex or Claude Code. If you choose Codex, it installs to:

${CODEX_HOME:-~/.codex}/skills/generate-swagger-types

If you choose Claude Code, it installs to:

${CLAUDE_CONFIG_DIR:-~/.claude}/skills/generate-swagger-types

To skip the prompt, pass --agent:

swapper install-skill --agent claude-code

Optional flags:

| Option | Required | Default | Description | | --- | --- | --- | --- | | --agent | No | Interactive selector in TTY; codex in non-interactive shells | Target agent. Supports codex, claude-code, and claude | | --dest | No | Depends on --agent | Custom skill installation root | | --force | No | true | Overwrite the destination if the skill already exists | | --no-force | No | false | Fail when the destination skill already exists |

Examples:

swapper install-skill --dest ~/.codex/skills
swapper install-skill --agent claude-code
swapper install-skill --no-force

Restart Codex or Claude Code after installation so the new skill can be loaded.

Generation Behavior

Incremental merge is the default mode:

  • Existing types.ts and index.ts files are read first
  • Newly generated types are merged into types.ts
  • Newly generated functions are merged into index.ts
  • Existing types and functions with the same name are replaced by the latest generated versions

When --force is used:

  • types.ts and index.ts in the target directory are overwritten directly

Output Example

Running:

swapper \
  -u https://swagger-page.com/promotion/api/v2/api-docs \
  --tag activity \
  --dir ./api \
  --prefix /promotion/api \
  -r "import request from '@/utils/request';"

will generate:

api/
├── index.ts
└── types.ts

Where:

  • types.ts contains response, request body, and query parameter type definitions
  • index.ts contains request functions and import type statements

Development

Show help:

node bin/swapper.js --help

Run directly:

node bin/swapper.js \
  -u https://swagger-page.com/promotion/api/v2/api-docs \
  --tag activity \
  --dir ./api \
  --prefix /promotion/api \
  -r "import request from '@/utils/request';"