Skip to content

Commit c9015f3

Browse files
Update src/utils/helpers.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent af1b664 commit c9015f3

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/utils/helpers.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,38 @@ export function shouldIncludeOperationForMcp(
134134
operation: OpenAPIV3.OperationObject,
135135
defaultInclude: boolean = true
136136
): boolean {
137-
const opVal = normalizeBoolean((operation as any)['x-mcp']);
137+
const opRaw = (operation as any)['x-mcp'];
138+
const opVal = normalizeBoolean(opRaw);
138139
if (typeof opVal !== 'undefined') return opVal;
140+
if (typeof opRaw !== 'undefined') {
141+
console.warn(
142+
`Invalid x-mcp value on operation '${operation.operationId ?? '[no operationId]'}':`,
143+
opRaw,
144+
`-> expected boolean or 'true'/'false'. Falling back to path/root/default.`
145+
);
146+
}
139147

140-
const pathVal = normalizeBoolean((pathItem as any)['x-mcp']);
148+
const pathRaw = (pathItem as any)['x-mcp'];
149+
const pathVal = normalizeBoolean(pathRaw);
141150
if (typeof pathVal !== 'undefined') return pathVal;
151+
if (typeof pathRaw !== 'undefined') {
152+
console.warn(
153+
`Invalid x-mcp value on path item:`,
154+
pathRaw,
155+
`-> expected boolean or 'true'/'false'. Falling back to root/default.`
156+
);
157+
}
142158

143-
const rootVal = normalizeBoolean((api as any)['x-mcp']);
159+
const rootRaw = (api as any)['x-mcp'];
160+
const rootVal = normalizeBoolean(rootRaw);
144161
if (typeof rootVal !== 'undefined') return rootVal;
162+
if (typeof rootRaw !== 'undefined') {
163+
console.warn(
164+
`Invalid x-mcp value at API root:`,
165+
rootRaw,
166+
`-> expected boolean or 'true'/'false'. Falling back to defaultInclude=${defaultInclude}.`
167+
);
168+
}
145169

146170
return defaultInclude;
147171
}

0 commit comments

Comments
 (0)