pub struct MergePropertiesIntoOneOf;Expand description
A schemars Transform that merges top-level
properties and required fields from a wrapper struct into each oneOf variant.
This is used when a struct wraps a #[serde(flatten)] tagged enum: schemars places
the struct’s own fields as top-level properties alongside the enum’s oneOf.
OpenAPI code generators don’t handle this combination, so this transform pushes
the shared properties into each variant so they appear in the generated models.
§Usage
ⓘ
#[derive(schemars::JsonSchema, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[schemars(transform = MergePropertiesIntoOneOf)]
struct Wrapper {
sequence_number: u64,
timestamp: DateTime<Utc>,
#[serde(flatten)]
kind: MyEnum,
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for MergePropertiesIntoOneOf
impl RefUnwindSafe for MergePropertiesIntoOneOf
impl Send for MergePropertiesIntoOneOf
impl Sync for MergePropertiesIntoOneOf
impl Unpin for MergePropertiesIntoOneOf
impl UnsafeUnpin for MergePropertiesIntoOneOf
impl UnwindSafe for MergePropertiesIntoOneOf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more