Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit 45a2108

Browse files
committed
The MCPServer Schemable+extensions.swift failed to build because the Input.schema.schemaValue returns a SchemaValue object, but there was no direct way to convert this to the custom JSON type. I added an extension for SchemaValue to append the json variable
2 parents 985827e + e89cfe6 commit 45a2108

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

MCPServer/Sources/Convenience/Schemable+extensions.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,23 @@ extension JSONSchema_JSONValue {
159159
}
160160
}
161161
}
162+
163+
/*
164+
'Input.schema.schemaValue.json' would not be compiled because Input.schema.schemaValue returns a SchemaValue object, but there was no direct way to convert this to the custom JSON type. The existing extensions only handled:
165+
[KeywordIdentifier: JSONSchema_JSONValue] → JSON
166+
JSONSchema_JSONValue → JSON.Value
167+
But there was no extension for:
168+
SchemaValue → JSON
169+
*/
170+
extension SchemaValue {
171+
var json: JSON {
172+
switch self {
173+
case .boolean(let value):
174+
// For boolean schema values, create a simple JSON object
175+
return .object(["type": .string("boolean"), "default": .bool(value)])
176+
case .object(let dict):
177+
// Use the existing extension on [KeywordIdentifier: JSONSchema_JSONValue]
178+
return dict.json
179+
}
180+
}
181+
}

0 commit comments

Comments
 (0)