Use Extend Codegen CLI to generate Unreal SDK Plugin for Extend Service Extension
Overview
This article provides a step-by-step guide on how to generate a custom service plugin for the AccelByte Unreal SDK using the Extend Codegen CLI template pack.
A custom service module allows developers to leverage the AccelByte Unreal SDK to interact with custom service APIs. This includes services created with the Extend Service Extension, as well as any other custom service that provides an OpenAPI 2.0 specification.
The Extend Codegen CLI template pack consists of a Makefile and some Jinja template files. To generate the necessary code, simply invoke a single make command. This command triggers the Extend Codegen CLI to process the Jinja template files alongside an OpenAPI 2.0 JSON file, which outlines the custom service APIs, to generate the corresponding code.
Prerequisites
-
Extend Codegen CLI template pack ZIP for AccelByte Unreal SDK.
The template pack contains a Makefile and Jinja2 templates that drive the code generation process.
a. Download: Get the latest
accelbyte-unreal-sdk-template-pack.zipfrom GitHub Releases.b. Extract: Unzip to a working directory (e.g.,
~/Downloads/accelbyte-unreal-sdk-template-pack/).c. Contents: The template pack includes:
Makefile- Build automation script that orchestrates code generationconfig.yaml- Configuration for Jinja2 template renderingtemplates/- Jinja2 templates for generating C++ coderes/- Base plugin structure and resourcesversion.txt- Template pack version (e.g.,0.0.28)
tipThe
Makefileautomatically pulls the Docker image when you run themakecommand, so you don't need to manually download or install the Extend Codegen CLI. -
Windows 11 WSL2 or Linux Ubuntu 22.04 with the following tools installed.
a. Bash
bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
...b. Make
- To install from Ubuntu repository, run:
sudo apt update && sudo apt install make.
make --version
GNU Make 4.3
...c. Docker (Docker Engine v23.0+)
- To install from Ubuntu repository, run:
sudo apt update && sudo apt install docker.io docker-buildx docker-compose-v2. - Add your user to
dockergroup:sudo usermod -aG docker $USER. - Log out and log back in so that the changes take effect.
docker version
...
Server: Docker Desktop
Engine:
Version: 24.0.5
...infoThe
makecommand in the template pack uses Docker to run the Extend Codegen CLI. The Docker image (accelbyte/extend-codegen-cli) is automatically pulled if not already cached locally. - To install from Ubuntu repository, run:
-
AccelByte Unreal SDK installed in your Unreal project.
tipIf you haven't integrated the AccelByte Unreal SDK yet, follow the Unreal SDK setup guide first. The generated custom service plugin depends on the base AccelByte Unreal SDK.
-
A valid OpenAPI 2.0 JSON file for your custom service.
infoIf your custom service uses the Extend Service Extension, an OpenAPI 2.0 JSON file is automatically generated when the app is deployed in AccelByte Gaming Services (AGS). To access it, open the AGS
Admin Portal, navigate to your app'sApp Detailspage, clickOpen API Documentation, and find the JSON file link at the top of the Swagger UI page.Alternatively, if you need to get the OpenAPI 2.0 JSON file before deploying your app in AGS, see here.
tipValidating your OpenAPI 2.0 JSON file: Before proceeding, validate your OpenAPI spec using tools like Swagger Editor. Invalid specs will cause codegen errors.
Generate Unreal SDK Plugin for Extend Service Extension
-
Place the OpenAPI 2.0 JSON file for your custom service in the
my-unreal-project/specfolder. In this example, the file is namedguild.json. Next, copy theguild.jsonfile into the following three folders:Client,GameServer, andModels./path/to/my-unreal-project/
|__ ...
|__ MyAwesomeGame.uproject
|__ Config
|__ Content
|__ Plugins
|__ Source
|__ spec/
|__ Client/
| |__ guild.json <
|__ GameServer/
| |__ guild.json <
|__ Models/
| |__ guild.json <
|__ guild.jsonimportantThe Extend Codegen CLI template pack uses the OpenAPI 2.0 JSON file name as an identifier for your service: You can rename the file according to your preferences, but we recommend using all lowercase alphabets (a-z) to avoid issues generating code.
cautionWhen working with multiple OpenAPI 2.0 JSON files, identical
basePathvalues across files may cause issues in the generated code: We recommend ensuring that each OpenAPI 2.0 JSON file has a uniquebasePathvalue that matches the actual base path when the service is deployed. -
Unzip the downloaded Extend Codegen CLI template pack, navigate to the extracted folder, and run the
makecommand to generate the code.unzip accelbyte-unreal-sdk-template-pack.zipcd accelbyte-unreal-sdk-template-pack/make all \
CODEGEN_IMAGE_VERSION=0.0.28 \
PROJECT_PATH=/path/to/my-unreal-project \
SPEC_PATH=/path/to/my-unreal-project/spec \
PACKAGE_TYPE=plugin \
ADMIN_API_PATH=/admin/infoMake command parameters:
CODEGEN_IMAGE_VERSION: Docker image version from Docker Hub. Use the latest version listed (e.g.,0.0.28). Checkversion.txtin the template pack for the recommended version.PROJECT_PATH: Absolute path to your Unreal project root (where.uprojectfile is located). Must match the path from step 1.SPEC_PATH: Absolute path to thespecfolder containing your OpenAPI 2.0 JSON files. Must match the path from step 1.PACKAGE_TYPE: Choose one of two options:- module: Generates as a module within the existing
AccelByteUe4Sdkplugin (requires modifyingAccelByteUe4Sdk.uplugin). - plugin (recommended): Generates as a standalone plugin named
AccelByteUe4SdkCustomizationin your project'sPluginsfolder.
- module: Generates as a module within the existing
ADMIN_API_PATH(optional): Separates admin/server endpoints from client endpoints:- If specified (e.g.,
/admin/), ServerAPI includes endpoints with this path prefix, ClientAPI includes all others. - If not specified, both ServerAPI and ClientAPI include all available endpoints.
- If specified (e.g.,
tipWhat happens during code generation:
- Docker pulls the
accelbyte/extend-codegen-cli:<version>image (if not already cached). - The CLI reads your OpenAPI 2.0 JSON files from
SPEC_PATH. - Jinja2 templates from the template pack are processed with your OpenAPI spec data.
- Generated C++ code (
.hand.cppfiles) is written toPROJECT_PATH/Plugins/AccelByteUe4SdkCustomization/(forPACKAGE_TYPE=plugin). - The plugin structure includes:
Source/AccelByteUe4SdkCustomization/Public/Api/- API client classesSource/AccelByteUe4SdkCustomization/Public/Models/- Data modelsSource/AccelByteUe4SdkCustomization/AccelByteUe4SdkCustomization.Build.cs- Build configurationAccelByteUe4SdkCustomization.uplugin- Plugin descriptor
cautionBefore running the make command:
- Ensure the
Pluginsfolder exists in your Unreal project. If it doesn't exist, create it manually:mkdir -p /path/to/my-unreal-project/Plugins - Close Unreal Editor before generating code to avoid file lock issues.
- If regenerating code, consider backing up any manual modifications to the generated plugin.
tip[OPTIONAL] Manually pulling the Docker image: While the
makecommand automatically pulls the Docker image, you can pre-download it to verify connectivity or cache it:docker pull accelbyte/extend-codegen-cli:0.0.28To check the version and verify the image:
docker run --rm accelbyte/extend-codegen-cli:0.0.28 infoExpected output:
version: 0.0.28
hash: 6b93fa76ad531938c02b1be7e0ab0958fad8c72d
glibc: 2.31
sub-packages:
accelbyte-codegen-ext-openapi2-legacy:
version: 0.0.28
description: AccelByte Code Generator [Open API 2.0 - Legacy]To see available commands:
docker run --rm accelbyte/extend-codegen-cli:0.0.28 --help -
Add
AccelByteUe4SdkCustomizationintoPublicDependencyModuleNamesof your project.Build.csfile.PublicDependencyModuleNames.AddRange(new string[] { ..., "AccelByteUe4SdkCustomization" }); -
Verify the generated plugin files.
After running the
makecommand, verify that the plugin was generated successfully:ls -la /path/to/my-unreal-project/Plugins/AccelByteUe4SdkCustomization/Expected output (for
PACKAGE_TYPE=plugin):AccelByteUe4SdkCustomization/
|__ AccelByteUe4SdkCustomization.uplugin
|__ Resources/
| |__ Icon128.png
|__ Source/
|__ AccelByteUe4SdkCustomization/
|__ AccelByteUe4SdkCustomization.Build.cs
|__ Private/
| |__ AccelByteUe4SdkCustomizationModule.cpp
|__ Public/
|__ Api/
| |__ AccelByteGuildApi.h
| |__ AccelByteGuildApi.cpp
|__ Models/
|__ AccelByteGuildModels.htipKey files to check:
AccelByteUe4SdkCustomization.uplugin: Plugin descriptor with metadata and module definitionsAccelByte<ServiceName>Api.h/cpp: API client classes (e.g.,AccelByteGuildApi.hforguild.json)AccelByte<ServiceName>Models.h: Data models for request/response structuresAccelByteUe4SdkCustomization.Build.cs: Build configuration with dependencies
-
[OPTIONAL] If
PACKAGE_TYPEis set to module, you need to add theAccelByteUe4SdkCustomizationmodule in theAccelByteUe4Sdk.upluginfile.{
"Name": "AccelByteUe4SdkCustomization",
"Type": "Runtime",
"LoadingPhase": "PreDefault"
}
Integrate Extend Service Extension API into your Unreal project
-
Include the API from the
AccelByteUe4SdkCustomizationplugin.// #include "Api/AccelByte<ApiName>Api.h"
#include "Api/AccelByteGuildApi.h" -
Call the API function.
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
// ApiClient->GetApiPtr<AccelByte::Api::<ApiName>>()->SomeFunction(...);tipIf you need to override the
ServerUrlof your custom service and/or thebasePath, refer to the guide for Enabling environment switching for Unreal.
Additional Resources
- Extend Codegen CLI GitHub Repository - Source code, documentation, and issue tracker
- Extend Codegen CLI Docker Hub - Available Docker image versions
- Jinja2 Documentation - Official Jinja2 template engine documentation
- OpenAPI 2.0 Specification - OpenAPI 2.0 (Swagger) specification reference
Understanding the Code Generation Process
The Extend Codegen CLI uses a template-based approach powered by Jinja2 to generate Unreal SDK code:
- Input: OpenAPI 2.0 JSON file(s) describing your custom service API
- Processing: The CLI parses the spec using
OA2LegacyProcessorto extract endpoints, models, and parameters - Template Rendering: Jinja2 templates in
templates/sdk_customization/are populated with parsed data - Output: Complete Unreal Engine plugin with API classes, models, and build system integration
Template Structure
The template pack generates code from these main templates:
Client-operations-decl.j2/Client-operations-def.j2→ Client API headers and implementationsGameServer-operations-decl.j2/GameServer-operations-def.j2→ Server API headers and implementationsoperations-models.j2→ Model classes for request/response structuresClient-settings-decl.j2/Client-settings-def.j2→ Configuration classes
File Naming Convention
Generated files use the OpenAPI JSON filename (converted to PascalCase):
| OpenAPI File | Generated API Header | Generated API Implementation | Generated Models |
|---|---|---|---|
guild.json | AccelByteGuildApi.h | AccelByteGuildApi.cpp | AccelByteGuildModels.h |
tournament.json | AccelByteTournamentApi.h | AccelByteTournamentApi.cpp | AccelByteTournamentModels.h |
For a deep dive into Jinja2 templates, custom filters, and advanced debugging techniques, see Extend Codegen CLI - Templates and Debugging.
Troubleshooting
Code generation fails with "Docker not found"
Symptom: make: docker: Command not found or similar error.
Solution:
- Verify Docker is installed:
docker --version - Ensure Docker daemon is running:
docker ps - Check user permissions:
docker run hello-world - If permission denied, add user to docker group:
sudo usermod -aG docker $USERand log out/in
Code generation fails with "Invalid OpenAPI specification"
Symptom: Codegen CLI reports validation errors or fails to parse the OpenAPI JSON file.
Solution:
- Validate your OpenAPI 2.0 spec using Swagger Editor
- Ensure the spec version is OpenAPI 2.0 (not 3.0+)
- Check for:
- Missing required fields (
swagger,info,paths) - Invalid JSON syntax (trailing commas, unquoted keys)
- Undefined schema references (
$refpointing to non-existent definitions)
- Missing required fields (
- If using Extend Service Extension, ensure the app is deployed and the OpenAPI spec is generated correctly
Generated code doesn't compile in Unreal
Symptom: Build errors in Unreal Editor after adding the generated plugin.
Common causes and solutions:
-
Missing AccelByte SDK dependency:
- Error:
Cannot open include file: 'Core/AccelByteRegistry.h' - Solution: Ensure AccelByte Unreal SDK is installed and added to your project's dependencies
- Error:
-
Duplicate symbols or conflicting basePath:
- Error:
Multiple definitions of...or linking errors - Solution: Ensure each OpenAPI JSON file has a unique
basePathvalue
- Error:
-
Invalid C++ identifiers:
- Error: Syntax errors in generated code
- Solution: Use lowercase alphabets (a-z) for OpenAPI JSON filenames. Avoid special characters, numbers, or uppercase letters.
-
Plugin not loaded:
- Error:
Plugin 'AccelByteUe4SdkCustomization' failed to load - Solution: Check
AccelByteUe4SdkCustomization.upluginis valid JSON and the plugin is enabled in your.uprojectfile
- Error:
-
Outdated template pack:
- Error: Generated code uses deprecated SDK APIs
- Solution: Download the latest template pack from GitHub Releases
API calls return 404 or fail at runtime
Symptom: Generated API functions compile but fail when called from your game code.
Solution:
- Verify the custom service is deployed and accessible
- Check the
ServerUrlconfiguration in your Unreal project settings - Ensure the
basePathin the OpenAPI spec matches the deployed service's base path - Enable SDK logging to inspect the actual HTTP requests being made
Multiple OpenAPI specs cause conflicts
Symptom: Compilation errors when using multiple custom services.
Solution:
- Ensure each OpenAPI JSON file has a unique
basePathvalue (e.g.,/guild,/tournament,/leaderboard) - Use unique filenames for each service (e.g.,
guild.json,tournament.json) - Verify no duplicate endpoint paths across different specs
- If conflicts persist, generate plugins separately and use different plugin names
Regenerating code overwrites manual changes
Symptom: Custom modifications to generated code are lost when regenerating.
Solution:
- Don't modify generated code directly. Instead:
- Create wrapper classes that extend or compose the generated API classes
- Use Unreal's blueprint system to add custom logic
- Implement custom behavior in your game code, not in the plugin
- If you must modify generated code, maintain a separate patch file or version control branch
- Consider contributing improvements to the template pack if the generated code is insufficient
Docker image pull fails or is slow
Symptom: make command hangs or fails during Docker image download.
Solution:
- Check internet connectivity:
ping hub.docker.com - Verify Docker Hub is accessible:
docker pull hello-world - If behind a corporate proxy, configure Docker proxy settings
- Use a specific image version instead of
latestto avoid re-downloading - Pre-pull the image manually:
docker pull accelbyte/extend-codegen-cli:0.0.28
Need to debug the code generation process
Symptom: Generated code is incorrect or missing expected functionality.
Steps to debug:
- Inspect the OpenAPI spec: Ensure endpoints, models, and parameters are defined correctly
- Check the Jinja2 templates: Located in the template pack, these define how code is generated
- Review the Makefile: Shows the exact
docker runcommand and parameters passed to the CLI - Run with verbose logging: Add
VERBOSE=1to themakecommand to see detailed output - Use
--inspect verboseto explore the template environment: This powerful debugging tool reveals all available Jinja2 filters, functions, globals, and tests. See the Templates and Debugging guide for detailed usage. - Compare with working examples: Check the template pack's example specs and generated output
For additional support, refer to the Extend Codegen CLI GitHub repository or contact AccelByte support with:
- Your OpenAPI 2.0 JSON file
- The exact
makecommand used - Full error output from the code generation process
- Unreal Engine version and AccelByte SDK version