Skip to content

Generate only the API operations the CLI calls - #12

Merged
shaygun merged 1 commit into
mainfrom
chore/trim-generated-api-client
Nov 23, 2026
Merged

shaygun merged 1 commit into
mainfrom
chore/trim-generated-api-client

Conversation

@shaygun

@shaygun shaygun commented Nov 23, 2026

Copy link
Copy Markdown
Member

Summary

The committed generated client (internal/api/generated/) held the whole backend API: admin, billing, payout and webhook surface, plus every backend proto comment. This PR cuts it down to what the CLI calls and adds a guard so the full API can't come back.

  • scripts/openapi-allowlist.txt lists the 24 operations the CLI calls (agents, service accounts, organizations, metrics write credentials, platform versions).
  • scripts/openapi-allowlist.py runs in make generate-api-client after the Swagger 2 to OpenAPI 3 conversion. It keeps the allow-listed operations, the components they reach through $ref, and their tags, and strips descriptions, summaries, titles and examples.
  • scripts/openapi-leak-check.sh (make leak-check, run after generation and in CI) fails on:
    • admin, enforcement, impersonation, billing, payout, webhook and similar names
    • private and loopback IPs, .svc, cluster.local, .internal, localhost, and email addresses
    • free text left in the spec
    • operations in the spec or client that are not on the allow-list, allow-listed operations that are missing, and allow-listed operations the CLI doesn't call
    • Internal component names are not in the committed patterns. Maintainers can supply them with OPENAPI_LEAK_EXTRA_PATTERNS_FILE.
  • Regenerated from backend main (910ec00c) with oapi-codegen v2.8.0. The generated files drop from 3.35 MB to 215 KB (−85k lines).
  • CONTRIBUTING.md documents how to add an operation.

Notes

  • The committed openapi3.yaml had drifted from types.gen.go, which had hand edits (Organization.hypervisorDriver, the SolusVM and VirtFusion driver enums). Regenerating from the backend Swagger brings them back in line. The new spec also adds PLATFORM_DRIVER_PTERODACTYL from backend main.
  • The v1Agent schema still has fields such as kubeconfig, agentPublicIp, asn and ddosProvider. They belong to the public agent API the CLI uses, so the check does not ban them.
  • Git history still contains the old full client. This PR only stops it from shipping going forward. Whether to rewrite history is a separate decision.

Test plan

  • go build ./..., go vet ./..., make test, golangci-lint run all pass
  • make leak-check passes on the new client
  • The check fails on the old committed client (patterns, free text, unlisted operations) and on an unfiltered regeneration from current backend main (/v1/admin, Enforcement)
  • go mod tidy is a no-op

🤖 Generated with Claude Code

The committed client held the whole backend API, including admin,
billing and webhook surface and every backend proto comment. Now
make generate-api-client keeps only the operations listed in
scripts/openapi-allowlist.txt, the schemas they reach, and no free
text. scripts/openapi-leak-check.sh runs after generation and in CI.
It fails on unlisted or uncalled operations, leftover descriptions,
admin and billing names, private IPs, internal hostnames and emails.
Extra private patterns can come from OPENAPI_LEAK_EXTRA_PATTERNS_FILE.

Regenerated from the backend main Swagger (910ec00c) with
oapi-codegen v2.8.0. The generated files drop from 3.35 MB to 215 KB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shaygun
shaygun merged commit cfd697b into main Nov 23, 2026
2 of 3 checks passed
@shaygun
shaygun deleted the chore/trim-generated-api-client branch November 23, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant