CLI Reference
Complete reference for all swagger-to-tanstack CLI commands and options.
generate
Generate TypeScript code from OpenAPI specifications.
Required Options
-i, --input <path>
Path to your Swagger/OpenAPI specification file (JSON or YAML). Can be a local file or URL.
Common Options
-o, --output <dir>
Output directory for generated files. Default: ./src/api
-t, --template <name>
Template to use. Options: tanstack-query, rtk-query, swr, react-query-kit, basic. Default: tanstack-query
--http-client <client>
HTTP client to use. Options: axios, fetch. Default: axios
--validator <validator>
Schema validator. Options: zod, yup. Default: zod
Filtering Options
--include-tags <tags>
Include only endpoints with specified tags (comma-separated).
--exclude-tags <tags>
Exclude endpoints with specified tags (comma-separated).
--strip-base-path [path]
Strip base path from routes.
Advanced Options
--preserve-modified
Skip overwriting files that have been manually modified.
-u, --username <username>
Basic authentication username (for URLs).
-p, --password <password>
Basic authentication password (for URLs).
init
Initialize project with required boilerplate files.
This command creates:
lib/axios.ts- Axios instance configurationlib/query-keys.ts- Query keys factory (for TanStack Query)
watch
Watch Swagger file for changes and regenerate automatically.
Options
-i, --input <path>
Local Swagger spec file path to watch (required).
-o, --output <dir>
Output directory. Default: ./src/api
-t, --template <name>
Template to use. Default: tanstack-query
update
Update generated files while preserving user modifications.
Accepts the same options as the generate command, but automatically enables --preserve-modified.
validate
Validate Swagger/OpenAPI specification and display API information.
Options
-i, --input <path>
Path or URL to Swagger spec (required).
-u, --username <username>
Basic auth username (for URLs).
-p, --password <password>
Basic auth password (for URLs).
Displays: API title, version, number of paths, number of schemas, and available tags.
list-templates (list)
List all available templates, HTTP clients, and validators with comparison.
Displays detailed information about all templates including features, bundle sizes, and recommendations.
Global Options
--help, -h
Display help for any command.
--version, -V
Display version number.
Recommended Workflow
First Time Setup
Development Workflow
Before Generation