#[derive(Generable)]
{
// Attributes available to this derive:
#[generable]
#[serde]
}
Expand description
Re-export the derive macro when the derive feature is enabled.
Derives the Generable trait for a struct or enum.
This generates a JSON Schema that describes the type’s structure, which can be used for structured generation with FoundationModels.
§Attributes
§Container attributes (#[generable(...)] or #[serde(...)])
rename_all = "..."- Rename all fields/variants (camelCase, snake_case, etc.)description = "..."- Add a description to the schema
§Field/variant attributes (#[generable(...)] or #[serde(...)])
rename = "..."- Rename this field/variantskip- Skip this field/variant in the schemadescription = "..."- Add a descriptionminimum = N/maximum = N- Numeric boundsmin_length = N/max_length = N- String length boundspattern = "..."- Regex pattern for stringsmin_items = N/max_items = N- Array length bounds
§Example
ⓘ
use fm_rs::Generable;
#[derive(Generable)]
#[generable(rename_all = "camelCase")]
struct Person {
#[generable(description = "The person's full name")]
full_name: String,
#[generable(minimum = 0, maximum = 150)]
age: u32,
}Derives Generable for structs and unit enums.