#[derive(JsonSchema)]
{
// Attributes available to this derive:
#[serde]
}
Available on crate feature
macros only.Expand description
Derive rust_web_server::schema::JsonSchema for a struct with named
fields or an enum of unit variants.
The schema follows the type’s serde attributes, so it describes the JSON
serde_json reads and writes: container rename_all and default;
field rename, default, skip/skip_serializing/skip_deserializing
(left out) and skip_serializing_if (not required); variant rename.
Attributes that change the JSON’s shape — flatten, tag, content,
untagged, transparent, with/serialize_with/deserialize_with,
separate serialize/deserialize renames — are a compile error rather than a
schema that doesn’t match. Option fields are not required. Doc comments
become descriptions.
ⓘ
#[derive(serde::Serialize, serde::Deserialize, rust_web_server::JsonSchema)]
#[serde(rename_all = "camelCase")]
struct Item {
/// Stock keeping unit.
sku: String,
in_stock: u32,
note: Option<String>,
}