Skip to content

cli_reference

Francisco Dias edited this page Jul 1, 2026 · 4 revisions

CLI Reference

Usage

openapigen.exe --config <path/to/config.json>
openapigen.exe --init <folder>
openapigen.exe --input <spec> [--output <dir>] [--prefix <name>] [--docs]
openapigen.exe --help

The --config workflow is the primary mode — it reads all settings from a JSON config file and is the recommended approach for any project you return to repeatedly. The --input mode is a quick shortcut for one-off runs without a config file.


--config / -c

Run from a config file.

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

The config file specifies the input spec path, output folders, prefix, and which targets to emit. The tool also writes an openapigen.schema.json beside the config and patches $schema in the config to enable IDE autocomplete.

See Getting Started for the config format.


--init

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 IDE autocomplete

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


--input / -i (direct mode)

Path to an OpenAPI 3.x specification file.

openapigen.exe --input openapi.json
openapigen.exe --input path\to\spec.yaml

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

Note: the help text says "Path or URL" but URL input is not implemented — the tool checks FileInfo.Exists immediately and will fail if given a URL.


--output / -o (direct mode)

Output directory for generated files. Created automatically if it does not exist.

--output ./out
--output D:\gen\myapi

Default: build


--prefix (direct mode)

The namespace prefix used for all generated names. Affects four naming patterns:

Pattern Example (gm) Example (myapi)
Public functions gm_ myapi_
Private helpers _gm_ _myapi_
Struct names Gm Myapi
Macros / constants GM_ MYAPI_

Default: gm

See Naming Conventions for full details.


--docs (direct mode)

Also emit JSDoc stubs (schemas_codegen.js, function_codegen.js) alongside the GML files.

In config mode, doc output is controlled by "Docs.Enabled" in config.json.


--help / -h

Print usage and exit.


Exit codes

Code Meaning
0 Success
1 Bad / missing arguments
2 Option parse error
3 Input file or config file not found
5 Config JSON error or schema patch failure
6 OpenAPI spec parse 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

# Direct — JSON spec, output to ./out, default prefix
openapigen.exe --input openapi.json --output out

# Direct — YAML spec with custom prefix, also emit docs
openapigen.exe --input spec.yaml --output out --prefix petstore --docs

Clone this wiki locally