Struct SchemaCleanr
pub struct SchemaCleanr;Expand description
JSON Schema cleaner optimized for LLM tool calling.
Implementations§
Source§impl SchemaCleanr
impl SchemaCleanr
Sourcepub fn clean_for_gemini(schema: Value) -> Value
pub fn clean_for_gemini(schema: Value) -> Value
Clean schema for Gemini compatibility (strictest).
This is the most aggressive cleaning strategy, removing all keywords that Gemini’s API rejects.
Sourcepub fn clean_for_anthropic(schema: Value) -> Value
pub fn clean_for_anthropic(schema: Value) -> Value
Clean schema for Anthropic compatibility.
Sourcepub fn clean_for_openai(schema: Value) -> Value
pub fn clean_for_openai(schema: Value) -> Value
Clean schema for OpenAI compatibility (most permissive).
Zero-copy wrapper around Self::clean for Arc-shared tool schemas:
returns the same Arc when the pre-scan proves cleaning is a
no-op, deep-copying the tree only when a rewrite is actually needed.
Sourcepub fn needs_cleaning(schema: &Value, strategy: CleaningStrategy) -> bool
pub fn needs_cleaning(schema: &Value, strategy: CleaningStrategy) -> bool
Conservative read-only pre-scan: true when Self::clean with
strategy could change schema.
False positives are allowed (a flagged schema may clean to an equal
value); false negatives are not — !needs_cleaning(s) must imply
clean(s) == s. The triggers mirror every rewrite path in
clean_object: strategy-specific keyword removal, plus the
strategy-independent rewrites ($ref resolution, const → enum,
anyOf/oneOf simplification and sibling-type skipping, and
null-stripping in type arrays).
Sourcepub fn clean(schema: Value, strategy: CleaningStrategy) -> Value
pub fn clean(schema: Value, strategy: CleaningStrategy) -> Value
Clean schema with specified strategy.