pub fn schema_for<T: SchemarsJsonSchema>() -> JsonSchemaExpand description
The normalized input schema of T, generated with schemars.
T derives schemars::JsonSchema, so the crate that defines it depends on schemars = "1",
the major version strands uses (a type deriving another major’s trait does not satisfy the
bound). Typed structured output schemas and #[tool] parameter types of your own follow the
same rule.
#[derive(schemars::JsonSchema)]
struct Input {
/// City name.
city: String,
days: u32,
}
let schema = strands::tools::schema_for::<Input>();
assert_eq!(
serde_json::to_string(&schema)?,
serde_json::to_string(&serde_json::json!({
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name."},
"days": {"type": "integer", "minimum": 0}
},
"required": ["city", "days"]
}))?
);