You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
The includedMakefile is a convenience tool for generating the CloudOps Software Golang SDKs via the OpenAPI specification. It also integrates aninline schema lifter to fix compatibility issues with Go SDK generation.
Initial Setup
First, install theopenapi-generator. For thisMakefile to work, you will need to install it with Homebrew:
brew install openapi-generator
Next, set up the variables and folder structure:
cp variables.env.sample variables.envmake setup
Make sure to configure the variables invariables.env to match your environment.
This will create the following folders:
./api_specs → stores downloaded OpenAPI specs
./logs → stores generation logs
./sdk_out → stores generated SDKs
The Inline Schema Lifter
Many OpenAPI specs containinline schemas that cause problems with Golang SDK generation (invalid names, regex errors, or missing references). To solve this, we use theinline lifter script before passing the specs intoopenapi-generator.
How it Works
The lifter takes an input spec (JSON/YAML) and traverses it.
Inline schemas arelifted into#/components/schemas with auto-generated, sanitized names.
Invalid schema names are cleaned to meet Go’s naming restrictions.
Content wrapper issues are fixed so thatapplication/json blocks always contain properschema references.
The transformed spec is saved with the suffix_openapi_lifted.json.
This ensures that the final specs are compatible with Golang SDK generation.
Example
make generate_core
This will:
Download thecore_openapi.json spec
Run theinline lifter to producecore_openapi_lifted.json
Generate thecmc_core SDK into./sdk_out/cmc_core
Logs will be available in./logs/core_output.log.
Go Generator Config (go-generator-config.json)
This file contains additional configuration passed to theOpenAPI Generator when producing the Go SDKs.It controls aspects of code layout, naming conventions, and how models and APIs are organized.
enumClassPrefix: Ensures that generated enums are prefixed with their class name, reducing naming conflicts.
withSeparateModelsAndApi: Places models and API clients in separate packages for cleaner project organization.
modelPackage: Directory/package name where generated models are placed (models).
apiPackage: Directory/package name where generated API clients are placed (apis).
generateInterfaces: Generates interfaces for the APIs, which makes mocking and testing easier in Go.
How it’s used
Eachgenerate_* target in theMakefile passes the config file using:
-c ./go-generator-config.json
This means that all generated SDKs (core, aws, azure, vcd, acs) will follow the same structure and conventions defined here.If you need different configurations for different SDKs, you can create multiple config files and adjust the Makefile accordingly.
Generating the SDK
To fetch all specs:
make curl
To generate all SDKs:
make generate
You can also target specific clouds:
make generate_core
make generate_aws
make generate_azure
make generate_vcd
make generate_acs
The SDKs will be available in./sdk_out/<cloud> and the logs in./logs.
Backup Folders
Before regenerating specs/SDKs, you may want to back up your current environment:
make backup
This moves./api_specs and./sdk_out into timestamped backup directories.
Reset Folders
To clean up logs and SDKs:
make reset
To clean up the API specs:
make reset_spec
Warning: These commands delete data. Usemake backup if you need a rollback point.
Using the SDK
Since the SDK is not yet tracked as an official release, you must reference it manually in your Go project.