MCPcopy Index your code
hub / github.com/github/copilot-sdk / stripBooleanLiterals

Function stripBooleanLiterals

scripts/codegen/utils.ts:272–293  ·  view source on GitHub ↗
(schema: T)

Source from the content-addressed store, hash-verified

270 * keep just `type: "boolean"`. Other codegen runs on the original schema.
271 */
272export function stripBooleanLiterals<T>(schema: T): T {
273 if (typeof schema !== "object" || schema === null) return schema;
274 if (Array.isArray(schema)) {
275 return schema.map((item) => stripBooleanLiterals(item)) as unknown as T;
276 }
277 const result: Record<string, unknown> = {};
278 const src = schema as unknown as Record<string, unknown>;
279 const isBooleanType = src.type === "boolean";
280 for (const [key, value] of Object.entries(src)) {
281 if (isBooleanType && key === "const" && typeof value === "boolean") continue;
282 if (
283 isBooleanType &&
284 key === "enum" &&
285 Array.isArray(value) &&
286 value.every((v) => typeof v === "boolean")
287 ) {
288 continue;
289 }
290 result[key] = stripBooleanLiterals(value);
291 }
292 return result as T;
293}
294
295/**
296 * Normalize schema defects where a required property with a `$ref` to an object type

Callers 2

generateFunction · 0.85
generateRpcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…