Skip to content

Convert Value to FoundationModels schema #169

@purkylin

Description

@purkylin

I want to convert MCP tools to FoundationModels, but failed.

extension Value {
    func compatible() -> GenerationSchema {
        let data = try! JSONEncoder().encode(self)
        // failed
        return try! JSONDecoder().decode(GenerationSchema.self, from: data)
    }
}

The error output:

Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "additionalProperties", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"additionalProperties\", intValue: nil) (\"additionalProperties\").", underlyingError: nil))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions