proxmox/proxmox-api-macro/tests/updater.rs
Wolfgang Bumiller 34020ea3d6 change updater derivation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-10 12:03:29 +02:00

54 lines
1.1 KiB
Rust

use proxmox::api::api;
use proxmox::api::schema::Updater;
#[api]
/// An example of a simple struct type.
#[derive(Updater)]
#[serde(rename_all = "kebab-case")]
pub struct Simple {
/// A test string.
one_field: String,
/// An optional auto-derived value for testing:
#[serde(skip_serializing_if = "Option::is_empty")]
opt: Option<String>,
}
#[api(
properties: {
simple: { type: Simple },
},
)]
/// A second struct so we can test flattening.
#[derive(Updater)]
pub struct Complex {
/// An extra field not part of the flattened struct.
extra: String,
#[serde(flatten)]
simple: Simple,
}
#[api(
properties: {
simple: {
type: Simple,
optional: true,
},
},
)]
/// One of the baaaad cases.
#[derive(Updater)]
#[serde(rename_all = "kebab-case")]
pub struct SuperComplex {
/// An extra field not part of the flattened struct.
extra: String,
#[serde(skip_serializing_if = "Updater::is_empty")]
simple: Option<Simple>,
/// A field which should not appear in the updater.
#[updater(skip)]
not_in_updater: String,
}