Skip to content

fix(client-s3): use member xmlname if applicable #2835

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

Merged
merged 1 commit into from
Sep 27, 2021
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
4 changes: 4 additions & 0 deletions clients/client-s3/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export const serializeAws_restXmlCompleteMultipartUploadCommand = async (
let contents: any;
if (input.MultipartUpload !== undefined) {
contents = serializeAws_restXmlCompletedMultipartUpload(input.MultipartUpload, context);
contents = contents.withName("CompleteMultipartUpload");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
Expand Down Expand Up @@ -3493,6 +3494,7 @@ export const serializeAws_restXmlPutBucketLifecycleConfigurationCommand = async
let contents: any;
if (input.LifecycleConfiguration !== undefined) {
contents = serializeAws_restXmlBucketLifecycleConfiguration(input.LifecycleConfiguration, context);
contents = contents.withName("LifecycleConfiguration");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
Expand Down Expand Up @@ -4228,6 +4230,7 @@ export const serializeAws_restXmlPutObjectLegalHoldCommand = async (
let contents: any;
if (input.LegalHold !== undefined) {
contents = serializeAws_restXmlObjectLockLegalHold(input.LegalHold, context);
contents = contents.withName("LegalHold");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
Expand Down Expand Up @@ -4346,6 +4349,7 @@ export const serializeAws_restXmlPutObjectRetentionCommand = async (
let contents: any;
if (input.Retention !== undefined) {
contents = serializeAws_restXmlObjectLockRetention(input.Retention, context);
contents = contents.withName("Retention");
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ private void serializePayload(
writer.write("contents = $L;",
getInputValue(context, Location.PAYLOAD, "input." + memberName, member, target));

String targetName = target.getTrait(XmlNameTrait.class)
.map(XmlNameTrait::getValue)
.orElse(target.getId().getName());
if (
member.hasTrait(XmlNameTrait.class)
&& !member.getTrait(XmlNameTrait.class).get().getValue().equals(targetName)
) {
writer.write("contents = contents.withName($S);", member.getTrait(XmlNameTrait.class).get().getValue());
}

// XmlNode will serialize Structure and non-streaming Union payloads as XML documents.
if (target instanceof StructureShape
|| (target instanceof UnionShape && !target.hasTrait(StreamingTrait.class))
Expand Down
1 change: 1 addition & 0 deletions protocol_tests/aws-restxml/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ export const serializeAws_restXmlHttpPayloadWithMemberXmlNameCommand = async (
let contents: any;
if (input.nested !== undefined) {
contents = serializeAws_restXmlPayloadWithXmlName(input.nested, context);
contents = contents.withName("Hola");
body = '<?xml version="1.0" encoding="UTF-8"?>';
body += contents.toString();
}
Expand Down