Skip to content

Serialization

Wire serialization for connector request bodies.

Generated connector models expose idiomatic Python snake_case attribute names, but the connector service contract is the Swagger JSON property name. This module converts model instances into their wire representation, reading the Swagger property name from each dataclass field's metadata['wire_name'] and falling back to the attribute name when no metadata is present. This keeps the public Python surface idiomatic without changing the payload sent to the connector service.

Attributes

WIRE_NAME_METADATA_KEY module-attribute

WIRE_NAME_METADATA_KEY = 'wire_name'

ADDITIONAL_PROPERTIES_FIELD module-attribute

ADDITIONAL_PROPERTIES_FIELD = 'additional_properties'

Functions:

to_wire

to_wire(value: Any) -> Any

Recursively convert a value to its JSON wire representation.

Dataclasses become dictionaries keyed by their Swagger property names (from metadata['wire_name'] when present, otherwise the attribute name). None dataclass fields and None map values are omitted. additional_properties are merged into the containing object, mirroring the .NET [JsonExtensionData] behavior. Lists and tuples are converted element-by-element, and dictionaries are converted value-by-value with their keys preserved. Raw bytes and bytearray are returned unchanged so binary payloads are never JSON-encoded. All other scalar values pass through unchanged.

Parameters:

Name Type Description Default
value Any

The model, collection, or scalar to convert.

required

Returns:

Type Description
Any

The wire-format representation of value.