From bceac0a74ce9f97927dbeba6f9c0983564cbd99e Mon Sep 17 00:00:00 2001 From: Sri Charan Ratlan Date: Tue, 27 Oct 2026 11:33:42 +0530 Subject: [PATCH] fix(express): render Optional codec as union in OpenAPI generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- modules/express/openapi-generator.rc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/express/openapi-generator.rc.js b/modules/express/openapi-generator.rc.js index 20c587da3b3..5b1f11f2475 100644 --- a/modules/express/openapi-generator.rc.js +++ b/modules/express/openapi-generator.rc.js @@ -7,7 +7,7 @@ module.exports = (E) => { return { '.': { JsonFromStringifiedJson: () => E.right({ type: 'string' }), - Optional: (args) => E.right({ ...args[0], nullable: true }), + Optional: (_, innerSchema) => E.right({ type: 'union', schemas: [innerSchema, { type: 'undefined' }] }), }, 'io-ts-types': { Json: () => E.right({ type: 'object', properties: {}, required: [] }),