Skip to content

fix(express): render Optional codec as union in OpenAPI generation - #10074

Merged
Charan-Ratlan merged 1 commit into
masterfrom
WCI-2076
Nov 3, 2026
Merged

Charan-Ratlan merged 1 commit into
masterfrom
WCI-2076

Conversation

@Charan-Ratlan

Copy link
Copy Markdown
Contributor

The Optional handler in modules/express/openapi-generator.rc.js was written against the wrong signature: custom codec handlers receive (deref, ...renderedArgSchemas), but the handler treated its first parameter as an arguments array and spread args[0], which indexes the deref function and yields undefined. Every Optional(...)-wrapped field from @bitgo/public-types therefore degraded to an empty schema {} in the generated spec (e.g. AccountBaseBuildOptions.nonce, which should be oneOf: [string, number], BaseIntent.nonce, FeeOption.unit/formula/feeType, EthFillNonceBuildOptions.feeOptions).

Replace it with the handler from the wallet-platform SDK's codec config (bitgo-microservices packages/wallet-platform/sdk/ .openapi-generator.rc.js), copied verbatim: Optional maps to a union with undefined, matching public-types' own definition of Optional(type) as t.union([type, t.undefined]).

Regenerating the express spec with the CI generator (@api-ts/openapi-generator 6.1.2) against the lockfile-pinned @bitgo/public-types 6.90.0 yields 0 degraded schemas (was 6) and 203/211 components shared with wallet-platform.yaml schema-identical (was 130/211). Component-uniqueness lint collisions drop from 185 to 18; the remainder are wallet-platform-SDK-local schema mirrors (lightning, pendingApprovals) that drifted from public-types — BGMS-side follow-up tracked in WCI-2076

The Optional handler in modules/express/openapi-generator.rc.js was
written against the wrong signature: custom codec handlers receive
(deref, ...renderedArgSchemas), but the handler treated its first
parameter as an arguments array and spread args[0], which indexes
the deref function and yields undefined. Every Optional(...)-wrapped
field from @bitgo/public-types therefore degraded to an empty
schema {} in the generated spec (e.g. AccountBaseBuildOptions.nonce,
which should be oneOf: [string, number], BaseIntent.nonce,
FeeOption.unit/formula/feeType, EthFillNonceBuildOptions.feeOptions).

Replace it with the handler from the wallet-platform SDK's codec
config (bitgo-microservices packages/wallet-platform/sdk/
.openapi-generator.rc.js), copied verbatim: Optional maps to a
union with undefined, matching public-types' own definition of
Optional(type) as t.union([type, t.undefined]).

Regenerating the express spec with the CI generator
(@api-ts/openapi-generator 6.1.2) against the lockfile-pinned
@bitgo/public-types 6.90.0 yields 0 degraded schemas (was 6) and
203/211 components shared with wallet-platform.yaml schema-identical
(was 130/211). Component-uniqueness lint collisions drop from 185 to
18; the remainder are wallet-platform-SDK-local schema mirrors
(lightning, pendingApprovals) that drifted from public-types —
BGMS-side follow-up tracked in WCI-2076
@linear-code

linear-code Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

WCI-2076

@Charan-Ratlan
Charan-Ratlan deployed to breaking-changes-override October 27, 2026 06:14 — with GitHub Actions Active
@vmccarty

vmccarty commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@ralph-bitgo, review this PR.

@ralph-bitgo

ralph-bitgo Bot commented Nov 2, 2026

Copy link
Copy Markdown

Agent session started - follow the session here: https://ralph.bitgo-int.com/sessions/599d6ccb-ffeb-489c-a164-1064dca46a03

@ralph-bitgo

ralph-bitgo Bot commented Nov 2, 2026

Copy link
Copy Markdown

Findings

  • [P2] Generated fee options reject valid objects — openapi-generator.rc.js:10 renders EthFillNonceBuildOptions.feeOptions as a oneOf between FeeOption and EIP1559FeeOptions. Both schemas have no required properties and allow additional properties, so { "maxFeePerGas": 100 } matches both and fails oneOf, although the codec’s union accepts it. Use union semantics that allow overlapping alternatives, such as anyOf.

  • [P2] Add a generation regression test — The PR changes no tests. Exercise the generator and assert that an optional nonce retains its string-or-number schema and remains optional, and that overlapping fee-option alternatives accept valid inputs. The current generation check can succeed while emitting the original empty schemas.

The breaking-changes check also fails; its manual override is pending.

@vmccarty

vmccarty commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Breaking change override approved. Re: Spec-only fix. Note that you will continue seeing the audit check as failing. That’s expected, but non blocking now.

@Charan-Ratlan
Charan-Ratlan marked this pull request as ready for review November 3, 2026 09:23
@Charan-Ratlan
Charan-Ratlan requested review from a team as code owners November 3, 2026 09:23

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@Charan-Ratlan
Charan-Ratlan merged commit 427811d into master Nov 3, 2026
25 of 26 checks passed

This branch was successfully deployed

1 active deployment
breaking-changes-override — bceac0a7 Deployed Oct 27, 2026 by Charan-Ratlan via Linter Override #5953
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.

3 participants