Skip to content

Commit 7e634cf

Browse files
authored
fix(client-s3): use member xmlname if applicable (#2835)
1 parent 2923d66 commit 7e634cf

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

clients/client-s3/protocols/Aws_restXml.ts

+4
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ export const serializeAws_restXmlCompleteMultipartUploadCommand = async (
518518
let contents: any;
519519
if (input.MultipartUpload !== undefined) {
520520
contents = serializeAws_restXmlCompletedMultipartUpload(input.MultipartUpload, context);
521+
contents = contents.withName("CompleteMultipartUpload");
521522
body = '<?xml version="1.0" encoding="UTF-8"?>';
522523
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
523524
body += contents.toString();
@@ -3493,6 +3494,7 @@ export const serializeAws_restXmlPutBucketLifecycleConfigurationCommand = async
34933494
let contents: any;
34943495
if (input.LifecycleConfiguration !== undefined) {
34953496
contents = serializeAws_restXmlBucketLifecycleConfiguration(input.LifecycleConfiguration, context);
3497+
contents = contents.withName("LifecycleConfiguration");
34963498
body = '<?xml version="1.0" encoding="UTF-8"?>';
34973499
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
34983500
body += contents.toString();
@@ -4228,6 +4230,7 @@ export const serializeAws_restXmlPutObjectLegalHoldCommand = async (
42284230
let contents: any;
42294231
if (input.LegalHold !== undefined) {
42304232
contents = serializeAws_restXmlObjectLockLegalHold(input.LegalHold, context);
4233+
contents = contents.withName("LegalHold");
42314234
body = '<?xml version="1.0" encoding="UTF-8"?>';
42324235
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
42334236
body += contents.toString();
@@ -4346,6 +4349,7 @@ export const serializeAws_restXmlPutObjectRetentionCommand = async (
43464349
let contents: any;
43474350
if (input.Retention !== undefined) {
43484351
contents = serializeAws_restXmlObjectLockRetention(input.Retention, context);
4352+
contents = contents.withName("Retention");
43494353
body = '<?xml version="1.0" encoding="UTF-8"?>';
43504354
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
43514355
body += contents.toString();

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java

+10
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,16 @@ private void serializePayload(
272272
writer.write("contents = $L;",
273273
getInputValue(context, Location.PAYLOAD, "input." + memberName, member, target));
274274

275+
String targetName = target.getTrait(XmlNameTrait.class)
276+
.map(XmlNameTrait::getValue)
277+
.orElse(target.getId().getName());
278+
if (
279+
member.hasTrait(XmlNameTrait.class)
280+
&& !member.getTrait(XmlNameTrait.class).get().getValue().equals(targetName)
281+
) {
282+
writer.write("contents = contents.withName($S);", member.getTrait(XmlNameTrait.class).get().getValue());
283+
}
284+
275285
// XmlNode will serialize Structure and non-streaming Union payloads as XML documents.
276286
if (target instanceof StructureShape
277287
|| (target instanceof UnionShape && !target.hasTrait(StreamingTrait.class))

protocol_tests/aws-restxml/protocols/Aws_restXml.ts

+1
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ export const serializeAws_restXmlHttpPayloadWithMemberXmlNameCommand = async (
656656
let contents: any;
657657
if (input.nested !== undefined) {
658658
contents = serializeAws_restXmlPayloadWithXmlName(input.nested, context);
659+
contents = contents.withName("Hola");
659660
body = '<?xml version="1.0" encoding="UTF-8"?>';
660661
body += contents.toString();
661662
}

0 commit comments

Comments
 (0)