Skip to content

Commit 7c93265

Browse files
authored
Tag apigw struct fields with proper serde(skip_serializing_if) (#654)
1 parent 82bd8aa commit 7c93265

File tree

1 file changed

+12
-0
lines changed
  • lambda-events/src/event/apigw

1 file changed

+12
-0
lines changed

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

+12
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ where
8181
pub account_id: Option<String>,
8282
#[serde(default)]
8383
pub resource_id: Option<String>,
84+
#[serde(skip_serializing_if = "Option::is_none")]
8485
pub operation_name: Option<String>,
8586
#[serde(default)]
8687
pub stage: Option<String>,
@@ -125,6 +126,7 @@ pub struct ApiGatewayV2httpRequest {
125126
pub raw_path: Option<String>,
126127
#[serde(default)]
127128
pub raw_query_string: Option<String>,
129+
#[serde(skip_serializing_if = "Option::is_none")]
128130
pub cookies: Option<Vec<String>>,
129131
#[serde(deserialize_with = "deserialize_headers", default)]
130132
#[serde(serialize_with = "serialize_headers")]
@@ -133,14 +135,17 @@ pub struct ApiGatewayV2httpRequest {
133135
default,
134136
deserialize_with = "query_map::serde::aws_api_gateway_v2::deserialize_empty"
135137
)]
138+
#[serde(skip_serializing_if = "QueryMap::is_empty")]
136139
pub query_string_parameters: QueryMap,
137140
#[serde(deserialize_with = "deserialize_lambda_map")]
138141
#[serde(default)]
142+
#[serde(skip_serializing_if = "HashMap::is_empty")]
139143
pub path_parameters: HashMap<String, String>,
140144
pub request_context: ApiGatewayV2httpRequestContext,
141145
#[serde(deserialize_with = "deserialize_lambda_map")]
142146
#[serde(default)]
143147
pub stage_variables: HashMap<String, String>,
148+
#[serde(skip_serializing_if = "Option::is_none")]
144149
pub body: Option<String>,
145150
#[serde(default)]
146151
pub is_base64_encoded: bool,
@@ -163,6 +168,7 @@ where
163168
#[serde(default)]
164169
pub request_id: Option<String>,
165170
#[serde(bound = "", default)]
171+
#[serde(skip_serializing_if = "Option::is_none")]
166172
pub authorizer: Option<ApiGatewayV2httpRequestContextAuthorizerDescription<T1>>,
167173
/// The API Gateway HTTP API Id
168174
#[serde(default)]
@@ -176,6 +182,7 @@ where
176182
pub time: Option<String>,
177183
pub time_epoch: i64,
178184
pub http: ApiGatewayV2httpRequestContextHttpDescription,
185+
#[serde(skip_serializing_if = "Option::is_none")]
179186
pub authentication: Option<ApiGatewayV2httpRequestContextAuthentication>,
180187
}
181188

@@ -187,11 +194,14 @@ where
187194
T1: DeserializeOwned,
188195
T1: Serialize,
189196
{
197+
#[serde(skip_serializing_if = "Option::is_none")]
190198
pub jwt: Option<ApiGatewayV2httpRequestContextAuthorizerJwtDescription>,
191199
#[serde(deserialize_with = "deserialize_lambda_map")]
192200
#[serde(default)]
193201
#[serde(bound = "")]
202+
#[serde(skip_serializing_if = "HashMap::is_empty")]
194203
pub lambda: HashMap<String, T1>,
204+
#[serde(skip_serializing_if = "Option::is_none")]
195205
pub iam: Option<ApiGatewayV2httpRequestContextAuthorizerIamDescription>,
196206
}
197207

@@ -202,6 +212,7 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerJwtDescription {
202212
#[serde(deserialize_with = "deserialize_lambda_map")]
203213
#[serde(default)]
204214
pub claims: HashMap<String, String>,
215+
#[serde(skip_serializing_if = "Option::is_none")]
205216
pub scopes: Option<Vec<String>>,
206217
}
207218

@@ -215,6 +226,7 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerIamDescription {
215226
pub account_id: Option<String>,
216227
#[serde(default)]
217228
pub caller_id: Option<String>,
229+
#[serde(skip_serializing_if = "Option::is_none")]
218230
pub cognito_identity: Option<ApiGatewayV2httpRequestContextAuthorizerCognitoIdentity>,
219231
#[serde(default)]
220232
pub principal_org_id: Option<String>,

0 commit comments

Comments
 (0)