Skip to main content

FormatSerSchema

This class defines a schema for formatting serialization using a typed dictionary. It requires a specific type identifier and a formatting string, while allowing for an optional specification of when the formatting should be applied.

Attributes

AttributeTypeDescription
typeLiteral['format']Discriminator value used to identify the serialization schema as a string formatting type.
formatting_stringstrThe Python format string used to define how the object should be converted into a string representation.
when_usedWhenUsed = json-unless-noneDetermines the specific conditions under which this serialization format is applied, defaulting to 'json-unless-none'.

Methods


type()

def type() - > Literal['format']

Specifies the schema type identifier, which must be set to the literal string 'format' to indicate a formatting-based serialization strategy.

Returns

TypeDescription
Literal['format']The fixed literal string 'format' used for schema identification.

formatting_string()

def formatting_string() - > str

Defines the Python-style format string used to transform the input value into a formatted string representation.

Returns

TypeDescription
strThe template string containing placeholders for value formatting.

when_used()

def when_used() - > WhenUsed

Determines the conditions under which this formatting schema is applied during serialization, defaulting to 'json-unless-none'.

Returns

TypeDescription
WhenUsedA configuration value controlling the serialization context and null-handling behavior.