-
Notifications
You must be signed in to change notification settings - Fork 0
getting_started
Clone the repo and build the active solution.
git clone https://github.com/YoYoGames/GM-SwaggerCodeGen.git
cd GM-SwaggerCodeGen\GMExtensionCodeGen
dotnet build -c ReleaseThe binary lands at GMSwaggerCodeGen\bin\Release\net9.0\GMSwaggerCodeGen.exe.
The repository also contains a refactored solution under
OpenAPIGenerator/(fdias-dev-refactorbranch). Both solutions share the same CLI surface and produce identical output. TheOpenAPIGenerator/layout separates the language-agnostic code-writer library (codegencore) from the OpenAPI-specific generator (openapigen).
Point the tool at your OpenAPI spec:
GMSwaggerCodeGen.exe -i path\to\openapi.json -o out --prefix gmThe out/ directory will contain:
out/
generated_schemas.gml
generated_http.gml
generated_helpers.gml
controller_create.gml
controller_http.gml
controller_cleanup.gml
schemas_codegen.js (only with --lang docs or default)
function_codegen.js (only with --lang docs or default)
-
Add the GML files to your project (drag into the Script or Extension asset).
-
Create a persistent manager object — by convention,
obj_gm_core(the prefix matches--prefix). Make it persistent so it survives room transitions. -
Paste the controller snippets into the object's events:
File Event controller_create.gmlCreate controller_http.gmlAsync — HTTP controller_cleanup.gmlClean Up -
Place one instance of
obj_gm_corein your first room (or create it in code). The singleton helper (_gm_get_singleton()) will locate it automatically. -
Call an endpoint:
gm_my_endpoint(_param1, _param2, function(_status, _data, _request) { show_debug_message($"status={_status} data={json_stringify(_data)}"); });
Before calling secured endpoints, store the credential:
gm_request_auth_set_token("bearer_scheme_name", "your-jwt-here");The generated code injects it automatically on every request that requires that scheme.
Re-run the tool whenever the spec changes. The output files are fully generated — do not hand-edit them. Keep any custom converters or hooks in separate scripts.
GameMaker