Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
api-governance / spectral-lint (push) Has been cancelled
oas-ci / oas-validate (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Policy Simulation / policy-simulate (push) Has been cancelled
SDK Publish & Sign / sdk-publish (push) Has been cancelled
1.5 KiB
1.5 KiB
Go SDK (SDKGEN-63-003)
Deterministic generator settings for the Go SDK with context-first API design.
Prereqs
STELLA_OAS_FILEpointing to the frozen OpenAPI spec.- OpenAPI Generator CLI 7.4.0 jar at
tools/openapi-generator-cli-7.4.0.jar(override withSTELLA_OPENAPI_GENERATOR_JAR). - JDK 21 available on PATH (vendored at
../tools/jdk-21.0.1+12; setJAVA_HOMEif needed).
Generate
cd src/Sdk/StellaOps.Sdk.Generator
STELLA_OAS_FILE=ts/fixtures/ping.yaml \
STELLA_SDK_OUT=$(mktemp -d) \
go/generate-go.sh
Outputs land in out/go/ and are post-processed to normalize whitespace, inject the banner, and copy shared helpers (hooks.go).
Override STELLA_SDK_OUT to keep the repo clean during local runs.
Design Principles
- Context-first: All API methods accept
context.Contextas the first parameter for cancellation and deadline propagation. - Interfaces: Generated interfaces allow easy mocking in tests.
- RoundTripper hooks: Auth, retry, and telemetry are implemented as composable
http.RoundTripperwrappers viahooks.go. - Deterministic: Generation is reproducible given the same spec and toolchain lock.
Helpers
The post-process step copies hooks.go into the output directory providing:
AuthRoundTripper: Injects Authorization header from token providerRetryRoundTripper: Retries transient errors with exponential backoffTelemetryRoundTripper: Adds client/trace headersWithClientHooks: Composes round-trippers onto an*http.ClientPaginate[T]: Generic cursor-based pagination helper