Skip to content

Commit

Permalink
Fix flattened list and Fix issue of parsing result wrapper (#161)
Browse files Browse the repository at this point in the history
* update client-documentation-generator dependency to preview version

* fix issue with parsing flattened list

* fix result wrapper
  • Loading branch information
AllanZhengYP authored Dec 10, 2018
1 parent 3ad978b commit ab4b164
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/package-generator/src/ClientModuleGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ tsconfig.test.json

private devDependencies(): {[key: string]: string} {
const devDependencies: {[key: string]: string} = {
'@aws-sdk/client-documentation-generator': '^0.1.0',
'@aws-sdk/client-documentation-generator': '^0.1.0-preview.1',
'rimraf': '^2.6.2',
'typedoc': '^0.10.0',
'typescript': '^3.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,52 @@ describe('MemberRef', () => {
xmlNamespace: {
uri: 'foo',
},
}`
);
});

it('should include queryName traits in emitted object', () => {
const member: TreeModelMember = {
shape: {
type: 'string',
name: 'name',
documentation: 'documentation',
},
queryName: 'foo',
};
expect((new MemberRef(member)).toString())
.toEqual(
`{
shape: {
type: 'string',
},
queryName: 'foo',
}`
);
});

it('should include resultWrapper traits in emitted object', () => {
const member: TreeModelMember = {
shape: {
type: 'list',
name: 'list',
documentation: 'documentation',
member: {
shape: {
type: 'string',
name: 'string',
documentation: 'string',
},
name: 'string'
}
},
resultWrapper: 'foo',
};
expect((new MemberRef(member)).toString())
.toEqual(
`{
shape: list,
resultWrapper: 'foo',
}`
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class MemberRef {
streaming,
xmlAttribute,
xmlNamespace,
queryName,
resultWrapper
} = this.member;
const properties: Array<string> = [
`shape: ${!requiresImport(shape)
Expand All @@ -42,6 +44,12 @@ export class MemberRef {
if (xmlNamespace) {
properties.push(`xmlNamespace: ${new XmlNamespace(xmlNamespace)}`);
}
if (queryName) {
properties.push(`queryName: '${queryName}'`);
}
if (resultWrapper) {
properties.push(`resultWrapper: '${resultWrapper}'`);
}
return `
{
${new IndentedSection(properties.join(',\n'))},
Expand Down
2 changes: 1 addition & 1 deletion packages/xml-body-parser/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe('XmlBodyParser', () => {
});

it('should parse flattened list', () => {
let xml = '<xml><member>Jack</member><member>Rose</member></xml>';
let xml = '<xml><Items>Jack</Items><Items>Rose</Items></xml>';
let rules: Member = {
shape: {
type: "structure",
Expand Down
2 changes: 1 addition & 1 deletion packages/xml-body-parser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class XmlBodyParser implements BodyParser {
membershape = member.shape;
if (membershape.type === 'list') {
keyName = membershape.flattened ? (
membershape.member.locationName || "member"
membershape.member.locationName || keyName
) : keyName;
}
return keyName;
Expand Down

0 comments on commit ab4b164

Please sign in to comment.