-
-
Notifications
You must be signed in to change notification settings - Fork 284
Open
Description
I have some code like this:
pub(crate) struct PostVersionInfo {
// …
#[serde(skip_serializing_if = "Option::is_none")]
magnitude: Option<VersionBumpMagnitudeType>,
}This outputs a schema containing:
This is not valid, as null is specifically not a possibility (and validation should fail if null is specified as the value).
It seems there are a few related issues about this, but I can't quite figure out if this is supposed to be supported. It would be nice if this either:
- happened automatically when
skip_serializing_if = "Option::is_none"is specified, or - had a simple attribute to exclude
nullas a valid field value in the output JSON.
michaeltlombardi
Metadata
Metadata
Assignees
Labels
No labels
{ // … "magnitude": { "anyOf": [ { "$ref": "#/$defs/VersionBumpMagnitudeType" }, { "type": "null" } ] } }