GREsau / schemars

Generate JSON Schema documents from Rust code
https://graham.cool/schemars/
MIT License
791 stars 220 forks source link

Example for JsonSchema without definition references #271

Closed notdanilo closed 6 months ago

notdanilo commented 6 months ago

How can I generate a JsonSchema without $refs and definitions?

And what is schemars generate for serde_json::Value?

#[derive(Serialize, Deserialize, JsonSchema)]
/// The parameters for the multi_call function
struct MultiCallParameters {
    /// The function calls to make
    calls: Vec<FunctionCall>
}

#[derive(Clone, Serialize, Deserialize, JsonSchema)]
/// A function call
pub struct FunctionCall {
    /// The name of the function
    pub name: String,
    /// The arguments to the function
    pub arguments: serde_json::Value
}

This is becoming extremely necessary now that Large Language Models are using JsonSchemas (without external definition references) for function calls.

notdanilo commented 6 months ago

I found a way to do it in the examples.