MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / schema

Function schema

crates/opencode-provider/src/transform.rs:1384–1397  ·  view source on GitHub ↗

Sanitize a JSON schema for Gemini/Google models. - Convert integer enums to string enums - Recursive sanitization of nested objects/arrays - Filter required array to only include fields in properties - Remove properties/required from non-object types - Handle empty array items

(model: &models::ModelInfo, input_schema: serde_json::Value)

Source from the content-addressed store, hash-verified

1382/// - Remove properties/required from non-object types
1383/// - Handle empty array items
1384pub fn schema(model: &models::ModelInfo, input_schema: serde_json::Value) -> serde_json::Value {
1385 let provider_id = model.id.to_lowercase();
1386 let api_id = model
1387 .provider
1388 .as_ref()
1389 .and_then(|p| p.api.as_deref())
1390 .unwrap_or("");
1391
1392 if provider_id == "google" || api_id.contains("gemini") {
1393 sanitize_gemini(input_schema)
1394 } else {
1395 input_schema
1396 }
1397}
1398
1399fn sanitize_gemini(obj: serde_json::Value) -> serde_json::Value {
1400 use serde_json::{json, Map, Value};

Callers 2

Calls 2

sanitize_geminiFunction · 0.85
containsMethod · 0.80

Tested by 2