forked from Proxmox/proxmox
fixup schema entry for updaters with explicit types
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
34020ea3d6
commit
783cbcb499
@ -498,9 +498,8 @@ fn handle_updater_field(
|
||||
}
|
||||
};
|
||||
|
||||
field_schema.optional = field.ty.clone().into();
|
||||
|
||||
let span = Span::call_site();
|
||||
field_schema.optional = field.ty.clone().into();
|
||||
let updater = syn::TypePath {
|
||||
qself: Some(syn::QSelf {
|
||||
lt_token: syn::token::Lt { spans: [span] },
|
||||
@ -515,6 +514,16 @@ fn handle_updater_field(
|
||||
&["proxmox", "api", "schema", "Updatable", "Updater"],
|
||||
),
|
||||
};
|
||||
|
||||
// we also need to update the schema to point to the updater's schema for `type: Foo` entries
|
||||
if let SchemaItem::ExternType(path) = &mut field_schema.schema.item {
|
||||
*path = syn::ExprPath {
|
||||
attrs: Vec::new(),
|
||||
qself: updater.qself.clone(),
|
||||
path: updater.path.clone(),
|
||||
};
|
||||
}
|
||||
|
||||
field.ty = syn::Type::Path(updater);
|
||||
|
||||
if field_schema.flatten_in_struct {
|
||||
|
@ -38,7 +38,7 @@ pub struct Complex {
|
||||
},
|
||||
)]
|
||||
/// One of the baaaad cases.
|
||||
#[derive(Updater)]
|
||||
#[derive(Default, Updater)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct SuperComplex {
|
||||
/// An extra field not part of the flattened struct.
|
||||
|
Loading…
Reference in New Issue
Block a user