Skip to content
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

fix: adding default value for list members for awsQueryCompatible for… #4542

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "awsQueryCompatible",
"description": "set default list member value for awsQueryCompatible"
}
5 changes: 5 additions & 0 deletions lib/json/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ function translateStructure(structure, shape) {

var struct = {};
var shapeMembers = shape.members;
var isAwsQueryCompatible = shape.api && shape.api.awsQueryCompatible;
util.each(shapeMembers, function(name, memberShape) {
var locationName = memberShape.isLocationName ? memberShape.name : name;
if (Object.prototype.hasOwnProperty.call(structure, locationName)) {
var value = structure[locationName];
var result = translate(value, memberShape);
if (result !== undefined) struct[name] = result;
} else if (isAwsQueryCompatible && memberShape.defaultValue) {
if (memberShape.type === 'list') {
struct[name] = typeof memberShape.defaultValue === 'function' ? memberShape.defaultValue() : memberShape.defaultValue;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason we only apply this to lists and not maps is because the XML behavior was only applied to lists

}
});
return struct;
Expand Down
38 changes: 38 additions & 0 deletions test/json/parser.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.