Documentation
¶
Index ¶
- func CoerceStringifiedJSON(schema *jsonschema.Schema, value any) (any, bool)
- func ExtractDefAsSchema(jsonSchema, defName string) (string, error)
- func ExtractReferencedDefs(jsonSchema, defName string) (map[string]any, error)
- func MustExtractDefAsSchema(jsonSchema, defName string) string
- func MustExtractReferencedDefs(jsonSchema, defName string) map[string]any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoerceStringifiedJSON ¶ added in v0.89.0
func CoerceStringifiedJSON(schema *jsonschema.Schema, value any) (any, bool)
CoerceStringifiedJSON walks value alongside schema and, wherever the schema unambiguously expects an object or array but the value is a string containing valid JSON of that kind, replaces the string with the parsed value. It returns the (possibly mutated) value and whether anything changed. It never errors: on any ambiguity or parse failure it leaves the value untouched so that downstream schema validation produces its normal error. It exists to work around MCP clients that JSON-encode object-typed tool arguments as strings (see https://github.com/anthropics/claude-code/issues/25865).
func ExtractDefAsSchema ¶
ExtractDefAsSchema extracts a specific definition from the $defs property of JSON schema by its name. The resulting schema's $defs will contain any other definitions that are referenced by the extracted definition. It returns the definition as a JSON schema string.
func ExtractReferencedDefs ¶
ExtractReferencedDefs extracts all definitions referenced by a specific definition in the $defs property of JSON schema. It returns a map of definition names to their corresponding JSON schema definitions. The resulting map will include the specified definition and any other definitions that are referenced by it.
func MustExtractDefAsSchema ¶
MustExtractDefAsSchema wraps ExtractDefAsSchema and panics if an error occurs.
func MustExtractReferencedDefs ¶
MustExtractReferencedDefs wraps ExtractReferencedDefs and panics if an error occurs.
Types ¶
This section is empty.