From c9015f395ecbe7d2c2fc36345c5bbd6b291d264f Mon Sep 17 00:00:00 2001 From: Fabricio Borgobello Date: Fri, 22 Aug 2025 11:58:27 +0200 Subject: [PATCH] Update src/utils/helpers.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/utils/helpers.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 7ab8917..6e36dca 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -134,14 +134,38 @@ export function shouldIncludeOperationForMcp( operation: OpenAPIV3.OperationObject, defaultInclude: boolean = true ): boolean { - const opVal = normalizeBoolean((operation as any)['x-mcp']); + const opRaw = (operation as any)['x-mcp']; + const opVal = normalizeBoolean(opRaw); if (typeof opVal !== 'undefined') return opVal; + if (typeof opRaw !== 'undefined') { + console.warn( + `Invalid x-mcp value on operation '${operation.operationId ?? '[no operationId]'}':`, + opRaw, + `-> expected boolean or 'true'/'false'. Falling back to path/root/default.` + ); + } - const pathVal = normalizeBoolean((pathItem as any)['x-mcp']); + const pathRaw = (pathItem as any)['x-mcp']; + const pathVal = normalizeBoolean(pathRaw); if (typeof pathVal !== 'undefined') return pathVal; + if (typeof pathRaw !== 'undefined') { + console.warn( + `Invalid x-mcp value on path item:`, + pathRaw, + `-> expected boolean or 'true'/'false'. Falling back to root/default.` + ); + } - const rootVal = normalizeBoolean((api as any)['x-mcp']); + const rootRaw = (api as any)['x-mcp']; + const rootVal = normalizeBoolean(rootRaw); if (typeof rootVal !== 'undefined') return rootVal; + if (typeof rootRaw !== 'undefined') { + console.warn( + `Invalid x-mcp value at API root:`, + rootRaw, + `-> expected boolean or 'true'/'false'. Falling back to defaultInclude=${defaultInclude}.` + ); + } return defaultInclude; }