Skip to main content

schema_for

Function schema_for 

Source
pub fn schema_for<T: JsonSchema>() -> Value
Expand description

Generate a JSON Schema Value from a Rust type.

Strips $schema and title root-level metadata so the output is ready to use as Tool::parameters.

ยงExample

use github_copilot_sdk::tool::{schema_for, JsonSchema};

#[derive(JsonSchema)]
struct Params {
    /// City name
    city: String,
}

let schema = schema_for::<Params>();
assert_eq!(schema["type"], "object");
assert!(schema["properties"]["city"].is_object());