Skip to content

cli_reference

Francisco Dias edited this page Aug 18, 2026 · 4 revisions

CLI Reference

Usage

openapigen.exe --config <path/to/config.json>
openapigen.exe --init <folder>
openapigen.exe --help

openapigen runs entirely from a config file. There is no direct-arguments mode — the spec path, prefix and every output location live in config.json, so a run is reproducible and reviewable.


--config / -c

Run from a config file.

openapigen.exe --config ./myapi/config.json

The config specifies the input spec, the output root, the prefix, and where each generated file goes. On every run the tool also refreshes openapigen.schema.json beside the config and patches the config's $schema key, so an editor can offer completion and validation.

See Getting Started for the full config format.


--init / -i

Bootstrap a config.json and openapigen.schema.json in the given folder.

openapigen.exe --init ./myapi

Creates:

  • ./myapi/config.json — default config pointing at ./openapi.json
  • ./myapi/openapigen.schema.json — JSON schema for editor autocomplete

Edit config.json to point "input" at your spec, then run with --config.

Note: -i is --init, matching extgen. It is not --input; that mode was removed.


--help / -h

Print usage and exit.


Input formats

Both JSON and YAML are supported. The format is chosen from the file extension (.yaml / .yml → YAML; anything else → JSON).

URLs are not supported — input must be a local file path, resolved relative to the config file.


Validation

Before generating, the parsed spec is checked by a set of rules. Every diagnostic is reported; any error stops the run.

Code Severity Meaning
IR_OP_001 Error¹ An operation has no operationId
IR_PATH_001 Error A path parameter is not present in its path template
IR_SYM_001 Error Two operations generate the same GML function name
IR_SYM_002 Error Two schemas share a name

¹ Downgraded to a warning when "requireOperationId": false.

Generated function names are permanent public API, and operationId is the only stable, author-controlled source for them — a path-derived name changes whenever the URL is refactored, silently breaking callers, and derived names collide. Set "requireOperationId": false only for a third-party spec you cannot edit.

Problems in the spec that do not prevent generation (a response missing its required description, for example) are reported as warnings and the run continues.


Exit codes

Code Meaning
0 Success
1 Bad / missing arguments
2 Option parse error
3 Config file not found
5 Config JSON error, path resolution failure, or schema patch failure
6 OpenAPI spec parse or validation error
30 Emitter failure
98 --init failure
99 Unhandled exception

Examples

# Bootstrap a config, then run it
openapigen.exe --init ./myapi
openapigen.exe --config ./myapi/config.json

# Regenerate after editing the spec
openapigen.exe --config ./myapi/config.json

Clone this wiki locally