serde_swift_fields

Attribute Macro serde_swift_fields 

Source
#[serde_swift_fields]
Expand description

Attribute macro for automatic serde field generation

Automatically adds appropriate serde attributes based on field configurations for clean JSON serialization without enum wrappers.

ยงUsage

Apply this attribute to message structs before the derive attributes:

use swift_mt_message_macros::{SwiftMessage, serde_swift_fields};
use serde::{Deserialize, Serialize};

#[serde_swift_fields]  // Apply this first
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftMessage)]
struct MT103 {
    #[field("20")]
    field_20: Field20,
}

This macro automatically:

  • Adds #[serde(skip_serializing_if = "Option::is_none")] to optional fields
  • Configures proper field naming for JSON output
  • Ensures clean serialization without enum variant wrappers