Skip to content

Commit

Permalink
fix: adding default value for list members for awsQueryCompatible for… (
Browse files Browse the repository at this point in the history
#4542)

* fix: adding default value for list members for awsQueryCompatible for json protocol

* Added changelog

---------

Co-authored-by: Ran Vaknin <[email protected]>
  • Loading branch information
RanVaknin and Ran Vaknin authored Dec 4, 2023
1 parent fb09502 commit b2e395e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-awsQueryCompatible-5c2d41f9.json
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;
}
}
});
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.

0 comments on commit b2e395e

Please sign in to comment.