Skip to content

Commit

Permalink
fix(clients): fix restXml protocol test for timestampFormat targets (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
srchase committed Jan 24, 2023
1 parent cdef3e5 commit 4beb93b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions clients/client-s3/src/protocols/Aws_restXml.ts
Expand Up @@ -8579,7 +8579,7 @@ const serializeAws_restXmlLambdaFunctionConfigurationList = (
const serializeAws_restXmlLifecycleExpiration = (input: LifecycleExpiration, context: __SerdeContext): any => {
const bodyNode = new __XmlNode("LifecycleExpiration");
if (input.Date != null) {
const node = __XmlNode.of("Date", input.Date.toISOString().split(".")[0] + "Z").withName("Date");
const node = __XmlNode.of("Date", (input.Date.toISOString().split(".")[0] + "Z").toString()).withName("Date");
bodyNode.addChildNode(node);
}
if (input.Days != null) {
Expand Down Expand Up @@ -8980,7 +8980,7 @@ const serializeAws_restXmlObjectLockRetention = (input: ObjectLockRetention, con
}
if (input.RetainUntilDate != null) {
const node = __XmlNode
.of("Date", input.RetainUntilDate.toISOString().split(".")[0] + "Z")
.of("Date", (input.RetainUntilDate.toISOString().split(".")[0] + "Z").toString())
.withName("RetainUntilDate");
bodyNode.addChildNode(node);
}
Expand Down Expand Up @@ -9729,7 +9729,7 @@ const serializeAws_restXmlTopicConfigurationList = (input: TopicConfiguration[],
const serializeAws_restXmlTransition = (input: Transition, context: __SerdeContext): any => {
const bodyNode = new __XmlNode("Transition");
if (input.Date != null) {
const node = __XmlNode.of("Date", input.Date.toISOString().split(".")[0] + "Z").withName("Date");
const node = __XmlNode.of("Date", (input.Date.toISOString().split(".")[0] + "Z").toString()).withName("Date");
bodyNode.addChildNode(node);
}
if (input.Days != null) {
Expand Down
Expand Up @@ -16,6 +16,7 @@
package software.amazon.smithy.aws.typescript.codegen;

import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.model.Model;
Expand Down Expand Up @@ -236,17 +237,20 @@ void serializeNamedMember(
// Grab the target shape so we can use a member serializer on it.
Shape target = context.getModel().expectShape(memberShape.getTarget());
XmlMemberSerVisitor inputVisitor = getMemberVisitor(inputLocation.get());

// Collected members must be handled with flattening and renaming.
if (serializationReturnsArray(target)) {
serializeNamedMemberFromArray(context, locationName, memberShape, target, inputVisitor);
} else {
// Handle @timestampFormat on members not just the targeted shape.
String valueProvider;
if (memberShape.hasTrait(TimestampFormatTrait.class)) {
if (memberShape.hasTrait(TimestampFormatTrait.class) || target.hasTrait(TimestampFormatTrait.class)) {
Optional<TimestampFormatTrait> timestampFormat = memberShape.getTrait(TimestampFormatTrait.class);
if (timestampFormat.isEmpty()) {
timestampFormat = target.getTrait(TimestampFormatTrait.class);
}
valueProvider = inputVisitor.getAsXmlText(target,
AwsProtocolUtils.getInputTimestampValueProvider(context, memberShape,
TIMESTAMP_FORMAT, inputLocation.get()) + ".toString()");
timestampFormat.get().getFormat(), inputLocation.get()) + ".toString()");
} else {
valueProvider = target.accept(inputVisitor);
}
Expand Down

0 comments on commit 4beb93b

Please sign in to comment.