Skip to content

Commit 52db8a0

Browse files
committed
add catchall feature to resolve #1017
Signed-off-by: Craig Disselkoen <[email protected]>
1 parent ee2e0d2 commit 52db8a0

File tree

77 files changed

+2765
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2765
-5
lines changed

lambda-events/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,7 @@ streams = []
125125
documentdb = []
126126
eventbridge = ["chrono", "serde_with"]
127127

128+
catch-all-fields = []
129+
128130
[package.metadata.docs.rs]
129-
all-features = true
131+
all-features = true

lambda-events/src/event/activemq/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use serde::{Deserialize, Serialize};
2+
#[cfg(feature = "catch-all-fields")]
3+
use serde_json::Value;
24
use std::collections::HashMap;
35

46
use crate::custom_serde::deserialize_lambda_map;
@@ -11,6 +13,12 @@ pub struct ActiveMqEvent {
1113
#[serde(default)]
1214
pub event_source_arn: Option<String>,
1315
pub messages: Vec<ActiveMqMessage>,
16+
/// Catchall to catch any additional fields that were present but not expected by this struct.
17+
/// Enabled with Cargo feature `catch-all-fields`.
18+
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
19+
#[cfg(feature = "catch-all-fields")]
20+
#[serde(flatten)]
21+
pub other: HashMap<String, Value>,
1422
}
1523

1624
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
@@ -41,13 +49,25 @@ pub struct ActiveMqMessage {
4149
#[serde(deserialize_with = "deserialize_lambda_map")]
4250
#[serde(default)]
4351
pub properties: HashMap<String, String>,
52+
/// Catchall to catch any additional fields that were present but not expected by this struct.
53+
/// Enabled with Cargo feature `catch-all-fields`.
54+
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
55+
#[cfg(feature = "catch-all-fields")]
56+
#[serde(flatten)]
57+
pub other: HashMap<String, Value>,
4458
}
4559

4660
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
4761
#[serde(rename_all = "camelCase")]
4862
pub struct ActiveMqDestination {
4963
#[serde(default)]
5064
pub physical_name: Option<String>,
65+
/// Catchall to catch any additional fields that were present but not expected by this struct.
66+
/// Enabled with Cargo feature `catch-all-fields`.
67+
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
68+
#[cfg(feature = "catch-all-fields")]
69+
#[serde(flatten)]
70+
pub other: HashMap<String, Value>,
5171
}
5272

5373
#[cfg(test)]

lambda-events/src/event/alb/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ use crate::{
77
use http::{HeaderMap, Method};
88
use query_map::QueryMap;
99
use serde::{Deserialize, Serialize};
10+
#[cfg(feature = "catch-all-fields")]
11+
use serde_json::Value;
12+
#[cfg(feature = "catch-all-fields")]
13+
use std::collections::HashMap;
1014

1115
/// `AlbTargetGroupRequest` contains data originating from the ALB Lambda target group integration
1216
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
@@ -30,13 +34,25 @@ pub struct AlbTargetGroupRequest {
3034
#[serde(default, deserialize_with = "deserialize_nullish_boolean")]
3135
pub is_base64_encoded: bool,
3236
pub body: Option<String>,
37+
/// Catchall to catch any additional fields that were present but not expected by this struct.
38+
/// Enabled with Cargo feature `catch-all-fields`.
39+
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
40+
#[cfg(feature = "catch-all-fields")]
41+
#[serde(flatten)]
42+
pub other: HashMap<String, Value>,
3343
}
3444

3545
/// `AlbTargetGroupRequestContext` contains the information to identify the load balancer invoking the lambda
3646
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
3747
#[serde(rename_all = "camelCase")]
3848
pub struct AlbTargetGroupRequestContext {
3949
pub elb: ElbContext,
50+
/// Catchall to catch any additional fields that were present but not expected by this struct.
51+
/// Enabled with Cargo feature `catch-all-fields`.
52+
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
53+
#[cfg(feature = "catch-all-fields")]
54+
#[serde(flatten)]
55+
pub other: HashMap<String, Value>,
4056
}
4157

4258
/// `ElbContext` contains the information to identify the ARN invoking the lambda
@@ -46,6 +62,12 @@ pub struct ElbContext {
4662
/// nolint: stylecheck
4763
#[serde(default)]
4864
pub target_group_arn: Option<String>,
65+
/// Catchall to catch any additional fields that were present but not expected by this struct.
66+
/// Enabled with Cargo feature `catch-all-fields`.
67+
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
68+
#[cfg(feature = "catch-all-fields")]
69+
#[serde(flatten)]
70+
pub other: HashMap<String, Value>,
4971
}
5072

5173
/// `AlbTargetGroupResponse` configures the response to be returned by the ALB Lambda target group for the request
@@ -65,6 +87,12 @@ pub struct AlbTargetGroupResponse {
6587
pub body: Option<Body>,
6688
#[serde(default, deserialize_with = "deserialize_nullish_boolean")]
6789
pub is_base64_encoded: bool,
90+
/// Catchall to catch any additional fields that were present but not expected by this struct.
91+
/// Enabled with Cargo feature `catch-all-fields`.
92+
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
93+
#[cfg(feature = "catch-all-fields")]
94+
#[serde(flatten)]
95+
pub other: HashMap<String, Value>,
6896
}
6997

7098
#[cfg(test)]

0 commit comments

Comments
 (0)