From 7c932659c74744d97f8a02de749e4fbf88008057 Mon Sep 17 00:00:00 2001 From: Thitat Auareesuksakul Date: Tue, 16 May 2023 00:22:59 +0900 Subject: [PATCH] Tag `apigw` struct fields with proper `serde(skip_serializing_if)` (#654) --- lambda-events/src/event/apigw/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lambda-events/src/event/apigw/mod.rs b/lambda-events/src/event/apigw/mod.rs index 80063911..88b44fec 100644 --- a/lambda-events/src/event/apigw/mod.rs +++ b/lambda-events/src/event/apigw/mod.rs @@ -81,6 +81,7 @@ where pub account_id: Option, #[serde(default)] pub resource_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub operation_name: Option, #[serde(default)] pub stage: Option, @@ -125,6 +126,7 @@ pub struct ApiGatewayV2httpRequest { pub raw_path: Option, #[serde(default)] pub raw_query_string: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub cookies: Option>, #[serde(deserialize_with = "deserialize_headers", default)] #[serde(serialize_with = "serialize_headers")] @@ -133,14 +135,17 @@ pub struct ApiGatewayV2httpRequest { default, deserialize_with = "query_map::serde::aws_api_gateway_v2::deserialize_empty" )] + #[serde(skip_serializing_if = "QueryMap::is_empty")] pub query_string_parameters: QueryMap, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] + #[serde(skip_serializing_if = "HashMap::is_empty")] pub path_parameters: HashMap, pub request_context: ApiGatewayV2httpRequestContext, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] pub stage_variables: HashMap, + #[serde(skip_serializing_if = "Option::is_none")] pub body: Option, #[serde(default)] pub is_base64_encoded: bool, @@ -163,6 +168,7 @@ where #[serde(default)] pub request_id: Option, #[serde(bound = "", default)] + #[serde(skip_serializing_if = "Option::is_none")] pub authorizer: Option>, /// The API Gateway HTTP API Id #[serde(default)] @@ -176,6 +182,7 @@ where pub time: Option, pub time_epoch: i64, pub http: ApiGatewayV2httpRequestContextHttpDescription, + #[serde(skip_serializing_if = "Option::is_none")] pub authentication: Option, } @@ -187,11 +194,14 @@ where T1: DeserializeOwned, T1: Serialize, { + #[serde(skip_serializing_if = "Option::is_none")] pub jwt: Option, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] #[serde(bound = "")] + #[serde(skip_serializing_if = "HashMap::is_empty")] pub lambda: HashMap, + #[serde(skip_serializing_if = "Option::is_none")] pub iam: Option, } @@ -202,6 +212,7 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerJwtDescription { #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] pub claims: HashMap, + #[serde(skip_serializing_if = "Option::is_none")] pub scopes: Option>, } @@ -215,6 +226,7 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerIamDescription { pub account_id: Option, #[serde(default)] pub caller_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub cognito_identity: Option, #[serde(default)] pub principal_org_id: Option,