Skip to content

chore: delete stale versioned clients when regenerating openapi/asyncapi codegen - #2322

Merged
mjuchli-da merged 1 commit into
canton-network:mainfrom
ayushsingh82:ayush/fix-openapi-codegen-1380
Aug 24, 2026
Merged

chore: delete stale versioned clients when regenerating openapi/asyncapi codegen#2322
mjuchli-da merged 1 commit into
canton-network:mainfrom
ayushsingh82:ayush/fix-openapi-codegen-1380

Conversation

@ayushsingh82

Copy link
Copy Markdown
Contributor

Summary

generate-openapi-clients.ts and generate-asyncapi-clients.ts write Canton ledger-api output into core/ledger-client-types/src/generated-clients with the Canton version embedded in the filename (openapi-<version>.ts, -paths.ts, -provider-types.ts, asyncapi-<version>.ts). Every Canton version bump created a new versioned file without removing the old one. The repo currently has 6 Canton versions' worth of these files checked in (3.4.12, 3.5.1, 3.5.8, 3.5.10, 3.5.14) -- most no longer referenced by version-config.json at all.

Added cleanupStaleVersionedFiles() (scripts/src/lib/utils.ts), run at the start of both scripts, which deletes any openapi-*/asyncapi-* file whose embedded version isn't currently configured for any network (so running for one network doesn't delete the other network's valid file).

Scope note

This fixes the scripts going forward. It deliberately does not:

  • delete the already-stale checked-in files (3.4.12, 3.5.1, 3.5.8), or
  • touch core/ledger-client-types/src/index.ts, which still hardcodes openapi-3.4.12/openapi-3.5.1 as the '3.4'/'3.5' LedgerApiVersion union.

That '3.4'/'3.5' scheme turned out to be load-bearing business logic well beyond this package -- default client versions and version-parsing logic in core/ledger-client and core/asyncapi-client, plus hardcoded cantonVersion: '3.4' test fixtures in wallet-gateway/remote. Both currently supported Canton versions (3.5.10 mainnet, 3.5.14 devnet) are already in the same "3.5" family, so deciding which patch backs that key going forward -- or restructuring the versioning scheme entirely -- needs a maintainer's call, not something a codegen cleanup script should decide. Happy to take that on as a follow-up if a maintainer can weigh in on intent.

Fixes #1380

Test plan

  • tsc -b clean in scripts/
  • eslint / prettier --check clean on all 3 changed files
  • Functionally tested cleanupStaleVersionedFiles against a fixture mirroring the repo's actual file set (all 6 checked-in Canton versions + an unrelated file): confirmed it removes exactly the 3.4.12/3.5.1/3.5.8 files (including .d.ts/.d.ts.map) and keeps 3.5.10/3.5.14 and the unrelated file
  • Could not run the actual script:generate:openapi/script:generate:asyncapi end-to-end (needs network access to fetch specs from GitHub releases) -- the cleanup step itself is verified in isolation above

…egen

Both generate-openapi-clients.ts and generate-asyncapi-clients.ts write
their Canton ledger-api output under core/ledger-client-types/src/generated-clients
with the Canton version embedded in the filename (openapi-<version>.ts,
-paths.ts, -provider-types.ts, asyncapi-<version>.ts). On every Canton
version bump this created a new versioned file without removing the
old one -- the repo currently has six versions' worth of these files
checked in (3.4.12, 3.5.1, 3.5.8, 3.5.10, 3.5.14), most of them for
versions no longer in version-config.json.

Add cleanupStaleVersionedFiles(), run before generation, which deletes
any openapi-*/asyncapi-* file in that directory whose embedded version
isn't one of the currently configured Canton versions across all
networks (so generating for one network doesn't delete the other
network's current files).

Scope note: this fixes the script going forward. It intentionally does
NOT delete the already-stale checked-in files or touch
core/ledger-client-types/src/index.ts, which still hardcodes
openapi-3.4.12/openapi-3.5.1 as the '3.4'/'3.5' LedgerApiVersion union.
That '3.4'/'3.5' scheme is load-bearing business logic used well beyond
this package (default client versions, version-parsing logic, and
hardcoded test fixtures in core/ledger-client, core/asyncapi-client, and
wallet-gateway/remote), and both currently supported Canton versions
(3.5.10 mainnet, 3.5.14 devnet) are already in the "3.5" family, so
picking which patch backs that key -- or restructuring the scheme
entirely -- needs a maintainer decision, not a script change.

Fixes canton-network#1380

Signed-off-by: ayushsingh82 <ayushsinghmi711@gmail.com>
@ayushsingh82

Copy link
Copy Markdown
Contributor Author

@alexmatson-da whenever you have a chance, would appreciate a look at this one.

@mjuchli-da mjuchli-da changed the title Delete stale versioned clients when regenerating openapi/asyncapi codegen chore: delete stale versioned clients when regenerating openapi/asyncapi codegen Aug 20, 2026
@mjuchli-da
mjuchli-da merged commit ef63040 into canton-network:main Aug 24, 2026
26 of 42 checks passed
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.

Fix codegen from canton openapi and asyncapi files

2 participants