pub fn derive_response_schema<T>() -> Valuewhere
T: JsonSchema + 'static,
Expand description
Generate a JSON Schema for the given T
inline, i.e. without
$ref
pointers to external definitions.
This is sufficient for most LLM providers, which currently expect the entire schema object inside a single request.
§Panics
This function panics only if the resulting [RootSchema
] cannot be
serialized into valid JSON – which should never happen as long as
schemars
works correctly.
§Example
use artificial_core::schema_util::derive_response_schema;
use schemars::JsonSchema;
#[derive(JsonSchema)]
struct Foo { bar: String }
let schema = derive_response_schema::<Foo>();
println!("{}", serde_json::to_string_pretty(&schema).unwrap());