Repository navigation
fix(express): render Optional codec as union in OpenAPI generation - #10074
Conversation
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
|
@ralph-bitgo, review this PR. |
|
Agent session started - follow the session here: https://ralph.bitgo-int.com/sessions/599d6ccb-ffeb-489c-a164-1064dca46a03 |
Findings
The breaking-changes check also fails; its manual override is pending. |
|
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. |
There was a problem hiding this comment.
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.
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