oag-cli
Command-line interface for oag — an OpenAPI 3.x code generator.
Installs a single binary called oag that parses OpenAPI specs and generates typed clients and servers.
Install
# From crates.io (requires Rust)
# Or via the install script (Linux/macOS)
|
Windows users can download binaries from the latest release.
Commands
oag generate
Generate code from an OpenAPI spec using the configuration in oag.yaml.
# Use config file (loads oag.yaml from current directory)
# Override the input spec path
Flags:
| Flag | Description |
|---|---|
-i, --input <PATH> |
Path to the OpenAPI spec file (YAML or JSON). Overrides the input field in the config file. |
Behavior:
- Loads
oag.yamlfrom the current directory (falls back to defaults if missing) - Parses the OpenAPI spec and transforms it into an intermediate representation (IR)
- For each generator in the
generatorsmap, generates code into the specified output directory - Writes a
README.mdin each output directory warning against manual edits - Auto-runs formatters if their config files are detected (e.g.,
biome.json,ruff.toml)
oag validate
Validate an OpenAPI spec and report its contents without generating any code.
Flags:
| Flag | Description |
|---|---|
-i, --input <PATH> |
(required) Path to the OpenAPI spec file to validate |
Output: Reports the spec version, title, number of paths, schemas, operations, and IR schemas. Exits with a non-zero code if the spec is invalid.
oag inspect
Dump the parsed intermediate representation (IR) so you can see exactly what oag understands from your spec. Useful for debugging or understanding how your spec maps to generated code.
# YAML output (default)
# JSON output
Flags:
| Flag | Description |
|---|---|
-i, --input <PATH> |
(required) Path to the OpenAPI spec file |
--format <FORMAT> |
Output format: yaml (default) or json |
Output: A structured summary containing:
info— spec title and versionschemas— all resolved schemas with their name and kind (object, enum, alias, union)operations— all operations with name, method, path, return kind (standard, sse, void), and tagsmodules— operation groups (by tag)
oag init
Create a oag.yaml configuration file in the current directory with sensible defaults and commented-out examples for all generators.
# Create config (fails if it already exists)
# Overwrite an existing config
Flags:
| Flag | Description |
|---|---|
--force |
Overwrite an existing oag.yaml file |
oag completions
Generate shell completion scripts for tab-completion of commands and flags.
# Bash
# Zsh
# Fish
# PowerShell
Arguments:
| Argument | Description |
|---|---|
<SHELL> |
(required) Target shell: bash, zsh, fish, powershell, elvish |
oag packs
Manage packs for code generation.
# List available packs (built-in + installed)
# Extract all built-in packs to the packs directory for customization
# Install a custom pack from a local directory
# Remove an installed pack
Subcommands:
| Subcommand | Description |
|---|---|
list |
List available template packs (built-in + installed) |
install <SOURCE> |
Install a pack from a local directory |
install --builtin |
Extract all built-in packs to the templates directory |
remove <ID> |
Remove an installed template pack |
path |
Print the template packs directory path |
Installed packs take precedence over built-in packs, allowing you to customize any built-in pack by extracting and modifying it.
Configuration
The CLI automatically loads oag.yaml from the current directory. Run oag init to create one with defaults.
See the root README for the full configuration reference, including all generator options, layout modes, scaffold settings, and naming strategies.
Environment variables
| Variable | Description |
|---|---|
RUST_LOG |
Control log verbosity (e.g., RUST_LOG=debug oag generate). Uses env_logger syntax. |
Exit codes
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Error (invalid spec, missing config, I/O failure, generation error) |
Depends on
oag-core— parser, IR, config, and template pack enginepacks/— built-in template packs (embedded at compile time)