This directory holds the one-command generator for the REST client. The
WebSocket client (websocket/) and the REST helpers (rest/client.go,
rest/iterator.go) are hand-written and are never touched by generation.
bash scripts/generate.shThat orchestrator does, in order:
- Pull the spec —
rest/scripts/pull_spec.jsdownloadshttps://api.massive.com/openapi, drops draft paths, forces a singledefaulttag, applies theoperationId → method-namerenames fromrest/scripts/operation-mappings.js, and writesrest/scripts/openapi.json(committed, so spec changes show up in PR diffs). Safety gate: the run aborts if the spec is missing or empty. - Pre-process — a
jqpass rewrites invalidtype: number+format: int32schemas totype: integer. - Generate — oapi-codegen
(config:
rest/scripts/oapi-codegen.yaml) emits the isolated filerest/gen/client.gen.go. Because all generated code lives in that one file underrest/gen/, regeneration only ever replaces it. Safety gate: the run aborts if no client file was produced. - Post-process —
rest/scripts/fix-go-clashes.jsrenames single-letter JSON field clashes (P/p,S/s,X/x,T/t→AskPrice,BidPrice, …) and runsgofmt.
The generator is pinned in scripts/generate.sh:
OAPI_CODEGEN_VERSION="v2.5.1"
and invoked as go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.5.1,
so a run is reproducible regardless of what oapi-codegen happens to be on
PATH. Diffs then reflect spec changes, not generator upgrades. Keep this in
lockstep with the cache comment in .github/workflows/sync-openapi.yml.
There is no
openapitools.jsonhere — that file configures the Javaopenapi-generator, which this Go SDK does not use.
.github/workflows/sync-openapi.yml runs scripts/generate.sh on a daily
schedule (and via Run workflow). When the regenerated output differs from
what's committed it:
- mints a short-lived GitHub App token (the default
GITHUB_TOKENcan't open PRs — org policy blocks it), - commits as the GitHub App's bot identity,
- pushes a unique branch
bot/openapi-sync-<date>-<run-id>and opens a brand-new[bot]-prefixed PR (never reusing an existing one, so author ≠ reviewer), - posts a Slack notification.
| Kind | Name | Purpose |
|---|---|---|
| Variable | MASSIVE_CLIENT_LIBRARY_AUTOMATION_APP_ID |
GitHub App id (App must be installed on this repo) |
| Secret | MASSIVE_CLIENT_LIBRARY_AUTOMATION_APP_PRIVATE_KEY |
GitHub App private key |
| Secret | SLACK_CLIENT_LIBRARY_WEBHOOK |
Slack notification (shared; optional — skipped if unset) |
| File | Role |
|---|---|
scripts/generate.sh |
The single orchestrator (this pipeline). |
rest/scripts/pull_spec.js |
Download + filter + rename the spec. |
rest/scripts/operation-mappings.js |
Owns the public Go method names (operationId → name). Language-specific — do not share with other SDKs or "fix" entries, as that renames functions. |
rest/scripts/oapi-codegen.yaml |
oapi-codegen config (package gen, output gen/client.gen.go). |
rest/scripts/fix-go-clashes.js |
Post-process single-letter field clashes + gofmt. |
rest/scripts/analyze-field-clashes.js |
Standalone diagnostic — not part of the pipeline. |
rest/scripts/generate-go-examples.js |
Standalone example-snippet generator — not part of the pipeline. |