Reputation: 127
I am using AWS APIG integration request template mapping to transform the user request into a specific format before sending it to the actual API.
Consider this example of integration request mapping template:
#set($inputRoot = $input.path('$'))
#set($data = $inputRoot.data)
{
#set($emplyeeData = $data.employee)
"data": {
"employeeDetails": {
"employeeId": "$emplyeeData.id",
"name": "$emplyeeData.name",
"middleName": "$emplyeeData.middleName"
"lastName": "$emplyeeData.lastName"
}
}
}
Here, the actual values of:
The employeeId, name and lastName values gets replaced perfectly after transformation.
But the "middleName": "$emplyeeData.middleName" gets replaced by "middleName": ""
Which looks something like this:
{
"data": {
"employeeDetails": {
"employeeId": "123",
"name": "John",
"middleName": "",
"lastName": "Doe"
}
}
}
And the resulting json will have the middleName value as an empty string instead of null value.
Is there any configuration in the AWS that needs to be enabled to pass the null keywords as it is and not get replaced with empty/blank value after transformation?
Upvotes: 0
Views: 34