Skip to content

cli_reference

Francisco Dias edited this page Jun 30, 2026 · 4 revisions

CLI Reference

GMSwaggerCodeGen.exe -i <spec> -o <dir> [--prefix <name>] [--lang <targets>]

Options

-i / --input (required)

Path to the OpenAPI 3.x specification file.

-i openapi.json
-i 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.

-o / --output

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

-o ./out          # relative
-o D:\gen\myapi   # absolute

Default: build

--prefix

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.

--lang

Comma-separated list of output targets. Available targets:

Target Output
gml generated_schemas.gml, generated_http.gml, generated_helpers.gml, controller_*.gml
docs schemas_codegen.js, function_codegen.js (gm-ext doc stubs)
--lang gml          # GML only
--lang docs         # doc stubs only
--lang gml,docs     # both (default)

Default: gml,docs

Exit codes

Code Meaning
0 Success
1 Argument parse error
2 Input file not found
3 Unknown --lang target

Examples

# Basic — JSON spec, output to ./out, default prefix
GMSwaggerCodeGen.exe -i openapi.json -o out

# YAML spec with custom prefix
GMSwaggerCodeGen.exe -i spec.yaml -o out --prefix petstore

# GML only (skip doc stubs)
GMSwaggerCodeGen.exe -i openapi.json -o out --lang gml

# Docs only (for updating an existing integration)
GMSwaggerCodeGen.exe -i openapi.json -o out --lang docs

Clone this wiki locally