quickaction-api-generator
v0.1.0
Published
API client generator for QuickAction projects.
Maintainers
Readme
QuickAction API Generator
___ _ _ _ _ _
/ _ \ _ _ (_) ___ | | __ / \ ___ | |_ (_) ___ _ __
| | | | | | | | | | / __| | |/ / / _ \ / __| | __| | | / _ \ | '_ \
| |_| | | |_| | | | | (__ | < / ___ \ | (__ | |_ | | | (_) | | | | |
\__\_\ \__,_| |_| \___| |_|\_\ /_/ \_\ \___| \__| |_| \___/ |_| |_|
Beautiful, minimal, and opinionated CLI to generate an OpenAPI-based
TypeScript client tailored for QuickAction projects.
https://github.com/TRICOLORS-STUDDIO/quickaction-api-generatorA tiny, friendly generator that scaffolds
redocly.yaml, installs suggested dependencies, generates TypeScript types from an OpenAPI document, and emits anopenapi-fetchclient insrc/services.
Features
- ✅ Generate
redocly.yamlto point at your OpenAPI JSON - ✅ Run
openapi-typescriptto producesrc/types/api-quickaction.d.ts - ✅ Create a ready-to-use
openapi-fetchclient insrc/services/api-quickaction.ts - ⚙️ Detects package manager and installs recommended packages (optional)
- 🎨 Interactive, friendly CLI with colorful output
Quick Start
Prerequisites
- Node.js >= 18
- Git (optional)
Install from source (development)
# clone
git clone https://github.com/quickaction/api-generator.git
cd api-generator
# install dev deps
npm install
# build the CLI
npm run build
# run the CLI locally
node ./bin/cli.js --helpInstall globally (optional)
# from the project root (requires npm publish or local link)
npm install -g .
# then use `quickaction-api` from anywhere
quickaction-api --helpUsage
Run the CLI to scaffold a QuickAction API client in your current project folder.
# Interactive (recommended)
node ./bin/cli.js
# Provide OpenAPI URL and skip prompts
node ./bin/cli.js --url https://api.quickaction.app/api-public-docs.json --yes
# Only generate types (if you already have redocly.yaml)
node ./bin/cli.js --skip-install
# Show version
node ./bin/cli.js --versionOptions
-u, --url <url>: OpenAPI JSON URL to generate types from-b, --base-url <url>: API base URL used by the generated client--skip-install: Skip installing recommended dependencies-f, --force: Overwrite existing files-y, --yes: Skip prompts and accept defaults-s, --silent: Minimal output
Examples
# Typical non-interactive setup
node ./bin/cli.js --url https://api.example.com/openapi.json --yes
# Force overwrite and install deps using your package manager
node ./bin/cli.js --forceWhat it creates
redocly.yaml— points the Redocly CLI (andopenapi-typescript) at your OpenAPI JSONsrc/types/api-quickaction.d.ts— generated TypeScript types (viaopenapi-typescript)src/services/api-quickaction.ts— a smallopenapi-fetchclient wrapper- Adds an npm script:
quickaction:apiwhich runsopenapi-typescript
If files already exist the CLI prompts before overwriting unless --force is used.
Development notes
- Build system:
tsup(seetsup.config.ts) - Entry points:
src/index.tsandsrc/cli/index.ts - Type system: TypeScript (see
tsconfig.json)
If you change messages or CLI behavior, run:
npm run buildTroubleshooting
- If you see
SyntaxError: Unexpected tokenwhen runningnode ./bin/cli.js, ensure your project'spackage.jsonis UTF-8 without a BOM. If it contains a BOM (U+FEFF) some Node JSON parsers can fail. To fix:
# remove BOM (POSIX)
awk 'NR==1{sub(/\xEF\xBB\xBF/,"")}{print}' package.json > package.json.fixed && mv package.json.fixed package.json- If dependencies fail to install, re-run using your package manager explicitly (e.g.,
pnpm,yarn, ornpm).
Contributing
We welcome contributions!
- Fork the repo
- Create a feature branch
- Run
npm installandnpm run build - Add tests where applicable and open a PR
Please keep changes small and focused. Use Prettier for formatting.
License & Support
This project is licensed under the MIT License.
If you need help, open an issue at https://github.com/TRICOLORS-STUDDIO/quickaction-api-generator/issues
Made with ❤️ by the QuickAction team — happy coding!
