-
Notifications
You must be signed in to change notification settings - Fork 0
getting_started
Clone the repo and build the solution.
git clone https://github.com/YoYoGames/GM-SwaggerCodeGen.git
cd GM-SwaggerCodeGen\OpenAPIGenerator
dotnet build -c ReleaseThe binary lands at openapigen\bin\Release\net9.0\openapigen.exe.
Bootstrap a config in a working folder, then point it at your spec:
openapigen.exe --init ./myapiThis creates ./myapi/config.json and ./myapi/openapigen.schema.json. Open config.json,
set "Input" to the path of your OpenAPI spec, and run:
openapigen.exe --config ./myapi/config.jsonGenerated files land in the folder specified by "Gml.OutputFolder" (default: ./myapi/build).
{
"$schema": "./openapigen.schema.json",
"Input": "./openapi.json",
"Prefix": "gm",
"Gml": {
"Enabled": true,
"OutputFolder": "./build"
},
"Docs": {
"Enabled": false,
"OutputFolder": "./build"
}
}For one-off runs without a config file:
openapigen.exe --input openapi.json --output out --prefix gmAdd --docs to also emit documentation stubs.
out/
generated_schemas.gml
generated_http.gml
generated_helpers.gml
controller_create.gml
controller_http.gml
controller_cleanup.gml
schemas_codegen.js (only with Docs.Enabled: true or --docs)
function_codegen.js (only with Docs.Enabled: true or --docs)
-
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 scheme name must match the key in components.securitySchemes of the spec. The
generated code injects the token 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