S2T

CLI Reference

Complete reference for all swagger-to-tanstack CLI commands and options.

generate

Generate TypeScript code from OpenAPI specifications.

bash

Required Options

-i, --input <path>

Path to your Swagger/OpenAPI specification file (JSON or YAML). Can be a local file or URL.

bash
bash

Common Options

-o, --output <dir>

Output directory for generated files. Default: ./src/api

bash

-t, --template <name>

Template to use. Options: tanstack-query, rtk-query, swr, react-query-kit, basic. Default: tanstack-query

bash

--http-client <client>

HTTP client to use. Options: axios, fetch. Default: axios

bash

--validator <validator>

Schema validator. Options: zod, yup. Default: zod

bash

Filtering Options

--include-tags <tags>

Include only endpoints with specified tags (comma-separated).

bash

--exclude-tags <tags>

Exclude endpoints with specified tags (comma-separated).

bash

--strip-base-path [path]

Strip base path from routes.

bash

Advanced Options

--preserve-modified

Skip overwriting files that have been manually modified.

bash

-u, --username <username>

Basic authentication username (for URLs).

-p, --password <password>

Basic authentication password (for URLs).

bash

init

Initialize project with required boilerplate files.

bash

This command creates:

  • lib/axios.ts - Axios instance configuration
  • lib/query-keys.ts - Query keys factory (for TanStack Query)

watch

Watch Swagger file for changes and regenerate automatically.

bash
Note: Watch mode only works with local files, not URLs.

Options

-i, --input <path>

Local Swagger spec file path to watch (required).

bash

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

bash
Important: Update mode ALWAYS preserves your modifications. Use 'generate' for fresh generation.

Accepts the same options as the generate command, but automatically enables --preserve-modified.

validate

Validate Swagger/OpenAPI specification and display API information.

bash

Options

-i, --input <path>

Path or URL to Swagger spec (required).

bash

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

bash
bash

Displays detailed information about all templates including features, bundle sizes, and recommendations.

Global Options

--help, -h

Display help for any command.

bash
bash

--version, -V

Display version number.

bash

Recommended Workflow

First Time Setup

bash

Development Workflow

bash

Before Generation

bash

👋 Hello and welcome!

I'm Armel Dakayao, Front-End Developer & creator of swagger-to-tanstack CLI.

Armel Dakayao

Senior Front-End Developer. I build scalable, user-friendly web & mobile apps with React,React Native, Next.js, and TypeScript.