Skip to content

Tag apigw struct fields with proper serde(skip_serializing_if) #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lambda-events/src/event/apigw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ where
pub account_id: Option<String>,
#[serde(default)]
pub resource_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub operation_name: Option<String>,
#[serde(default)]
pub stage: Option<String>,
Expand Down Expand Up @@ -125,6 +126,7 @@ pub struct ApiGatewayV2httpRequest {
pub raw_path: Option<String>,
#[serde(default)]
pub raw_query_string: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cookies: Option<Vec<String>>,
#[serde(deserialize_with = "deserialize_headers", default)]
#[serde(serialize_with = "serialize_headers")]
Expand All @@ -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<String, String>,
pub request_context: ApiGatewayV2httpRequestContext,
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub stage_variables: HashMap<String, String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub body: Option<String>,
#[serde(default)]
pub is_base64_encoded: bool,
Expand All @@ -163,6 +168,7 @@ where
#[serde(default)]
pub request_id: Option<String>,
#[serde(bound = "", default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub authorizer: Option<ApiGatewayV2httpRequestContextAuthorizerDescription<T1>>,
/// The API Gateway HTTP API Id
#[serde(default)]
Expand All @@ -176,6 +182,7 @@ where
pub time: Option<String>,
pub time_epoch: i64,
pub http: ApiGatewayV2httpRequestContextHttpDescription,
#[serde(skip_serializing_if = "Option::is_none")]
pub authentication: Option<ApiGatewayV2httpRequestContextAuthentication>,
}

Expand All @@ -187,11 +194,14 @@ where
T1: DeserializeOwned,
T1: Serialize,
{
#[serde(skip_serializing_if = "Option::is_none")]
pub jwt: Option<ApiGatewayV2httpRequestContextAuthorizerJwtDescription>,
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
#[serde(bound = "")]
#[serde(skip_serializing_if = "HashMap::is_empty")]
pub lambda: HashMap<String, T1>,
#[serde(skip_serializing_if = "Option::is_none")]
pub iam: Option<ApiGatewayV2httpRequestContextAuthorizerIamDescription>,
}

Expand All @@ -202,6 +212,7 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerJwtDescription {
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub claims: HashMap<String, String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub scopes: Option<Vec<String>>,
}

Expand All @@ -215,6 +226,7 @@ pub struct ApiGatewayV2httpRequestContextAuthorizerIamDescription {
pub account_id: Option<String>,
#[serde(default)]
pub caller_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cognito_identity: Option<ApiGatewayV2httpRequestContextAuthorizerCognitoIdentity>,
#[serde(default)]
pub principal_org_id: Option<String>,
Expand Down