Skip to content

CLI Reference

Swaggie is invoked via the swaggie command. All options can be provided via flags or via a configuration file.

Synopsis

bash
swaggie [options]

At minimum, you need either --config or --src:

bash
# Using a config file
swaggie -c swaggie.config.json

# Using flags directly
swaggie -s <spec-url-or-path> -o <output-file>

Options

FlagAliasTypeDefaultDescription
--config-cstringPath to a JSON configuration file. Mutually exclusive with --src.
--src-sstringURL or file path to the OpenAPI spec (.json or .yaml). Required when not using --config.
--out-ostringOutput file path. Omit to print generated code to stdout.
--template-tstringaxiosTemplate to use. One of: axios, fetch, xior, swr-axios, tsq-xior, ng1, ng2, or a path to a custom template directory.
--baseUrl-bstring""Default base URL baked into the generated client.
--mode-mstringfullGeneration mode: full (client + schemas) or schemas (types only).
--schemaStyle-dstringinterfaceSchema object style: interface or type.
--enumStylestringunionEnum declaration style: union or enum.
--dateFormatstringDateTypeScript type for date fields: Date or string.
--nullablesstringignoreNullable handling: ignore, include, or nullableAsOptional.
--preferAnybooleanfalseUse any instead of unknown for untyped values.
--skipDeprecatedbooleanfalseExclude deprecated operations from the output.
--servicePrefixstring""Prefix for generated service (client object) names.
--allowDotsbooleantrueUse dot notation for nested object query params (a.b=1 vs a[b]=1).
--arrayFormatstringrepeatArray serialization in query strings: indices, repeat, or brackets.
--version-VPrint the installed version number and exit.
--help-hShow the help message and exit.

Examples

Minimal — output to stdout

bash
swaggie -s https://petstore3.swagger.io/api/v3/openapi.json

The generated TypeScript is printed to stdout. Useful for piping:

bash
swaggie -s ./spec.json | prettier --parser typescript > ./src/api/client.ts

Minimal — write to file

bash
swaggie -s https://petstore3.swagger.io/api/v3/openapi.json -o ./src/api/client.ts

With config file

bash
swaggie -c swaggie.config.json

Override config file options via flags

CLI flags take precedence over config file values. This lets you override specific settings at call time:

bash
swaggie -c swaggie.config.json --template fetch --out ./src/api/client-fetch.ts

Generate only TypeScript schemas

bash
swaggie -s ./spec.json -o ./src/types.ts --mode schemas

Use the fetch template with dot-notation query params

bash
swaggie -s ./spec.json -o ./client.ts -t fetch --allowDots --arrayFormat repeat

Skip deprecated endpoints

bash
swaggie -s ./spec.json -o ./client.ts --skipDeprecated

Piping to a formatter

Swaggie's output is functional but may not match your project's whitespace style. Pipe it through a formatter as part of your workflow:

bash
# Prettier
swaggie -c swaggie.config.json && prettier ./src/api/client.ts --write

# Biome
swaggie -c swaggie.config.json && biome check ./src/api/client.ts --write

Exit codes

CodeMeaning
0Success
1Error — invalid options, spec load failure, generation error

Released under the MIT License.