fix: add boolean union type support for FastMCP optional booleans
This commit is contained in:
parent
bcba0dc007
commit
5469993e27
1 changed files with 18 additions and 0 deletions
|
|
@ -160,6 +160,15 @@ export function normalizeUnionType(schema: JsonSchemaType): JsonSchemaType {
|
||||||
return { ...schema, type: "string", anyOf: undefined };
|
return { ...schema, type: "string", anyOf: undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle anyOf with boolean and null (FastMCP pattern)
|
||||||
|
if (
|
||||||
|
schema.anyOf &&
|
||||||
|
schema.anyOf.some((t) => (t as JsonSchemaType).type === "boolean") &&
|
||||||
|
schema.anyOf.some((t) => (t as JsonSchemaType).type === "null")
|
||||||
|
) {
|
||||||
|
return { ...schema, type: "boolean", anyOf: undefined };
|
||||||
|
}
|
||||||
|
|
||||||
// Handle array type with string and null
|
// Handle array type with string and null
|
||||||
if (
|
if (
|
||||||
Array.isArray(schema.type) &&
|
Array.isArray(schema.type) &&
|
||||||
|
|
@ -169,6 +178,15 @@ export function normalizeUnionType(schema: JsonSchemaType): JsonSchemaType {
|
||||||
return { ...schema, type: "string" };
|
return { ...schema, type: "string" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle array type with boolean and null
|
||||||
|
if (
|
||||||
|
Array.isArray(schema.type) &&
|
||||||
|
schema.type.includes("boolean") &&
|
||||||
|
schema.type.includes("null")
|
||||||
|
) {
|
||||||
|
return { ...schema, type: "boolean" };
|
||||||
|
}
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue