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: supporte moving default lists for xml parser #3087

Merged
merged 3 commits into from
Feb 3, 2020
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
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-parser-5e14f8ef.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "parser",
"description": "Now we can disable inserting empty array in xml parser if the member doesn't exist in response."
}
3 changes: 2 additions & 1 deletion apis/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@
},
"s3control": {
"name": "S3Control",
"dualstackAvailable": true
"dualstackAvailable": true,
"xmlNoDefaultLists": true
},
"servicecatalog": {
"name": "ServiceCatalog",
Expand Down
7 changes: 7 additions & 0 deletions lib/model/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var Operation = require('./operation');
var Shape = require('./shape');
var Paginator = require('./paginator');
var ResourceWaiter = require('./resource_waiter');
var metadata = require('../../apis/metadata.json');

var util = require('../util');
var property = util.property;
Expand All @@ -16,6 +17,9 @@ function Api(api, options) {

api.metadata = api.metadata || {};

var serviceIdentifier = options.serviceIdentifier;
delete options.serviceIdentifier;

property(this, 'isApi', true, false);
property(this, 'apiVersion', api.metadata.apiVersion);
property(this, 'endpointPrefix', api.metadata.endpointPrefix);
Expand All @@ -30,6 +34,9 @@ function Api(api, options) {
property(this, 'abbreviation', api.metadata.serviceAbbreviation);
property(this, 'fullName', api.metadata.serviceFullName);
property(this, 'serviceId', api.metadata.serviceId);
if (serviceIdentifier) {
property(this, 'xmlNoDefaultLists', metadata[serviceIdentifier].xmlNoDefaultLists, false);
}

memoizedProperty(this, 'className', function() {
var name = api.metadata.serviceAbbreviation || api.metadata.serviceFullName;
Expand Down
4 changes: 3 additions & 1 deletion lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,9 @@ AWS.util.update(AWS.Service, {
if (api.isApi) {
svc.prototype.api = api;
} else {
svc.prototype.api = new Api(api);
svc.prototype.api = new Api(api, {
serviceIdentifier: superclass.serviceIdentifier
});
}
}

Expand Down
5 changes: 4 additions & 1 deletion lib/xml/browser_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ function parseStructure(xml, shape) {
getElementByTagName(xml, memberShape.name);
if (xmlChild) {
data[memberName] = parseXml(xmlChild, memberShape);
} else if (!memberShape.flattened && memberShape.type === 'list') {
} else if (
!memberShape.flattened &&
memberShape.type === 'list' &&
!shape.api.xmlNoDefaultLists) {
data[memberName] = memberShape.defaultValue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/xml/node_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function parseStructure(xml, shape) {
} else if (memberShape.isXmlAttribute &&
xml.$ && Object.prototype.hasOwnProperty.call(xml.$, xmlName)) {
data[memberName] = parseScalar(xml.$[xmlName], memberShape);
} else if (memberShape.type === 'list') {
} else if (memberShape.type === 'list' && !shape.api.xmlNoDefaultLists) {
data[memberName] = memberShape.defaultValue;
}
});
Expand Down
22 changes: 22 additions & 0 deletions test/xml/parser.spec.js

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