diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java index 59e2ee9f1881..7882d8cadb4a 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java @@ -125,7 +125,7 @@ private static boolean operationUsesAwsAuth(Model model, ServiceShape service, O if (testServiceId(service, "STS")) { Boolean isUnsignedCommand = SetUtils .of("AssumeRoleWithWebIdentity", "AssumeRoleWithSAML") - .contains(operation.getId().getName()); + .contains(operation.getId().getName(service)); return !isUnsignedCommand; } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java index a2fc0e61a928..c34b801ed786 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java @@ -68,19 +68,19 @@ public List getClientPlugins() { RuntimeClientPlugin.builder() .withConventions(AwsDependency.EC2_MIDDLEWARE.dependency, "CopySnapshotPresignedUrl", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> o.getId().getName().equals("CopySnapshot") + .operationPredicate((m, s, o) -> o.getId().getName(s).equals("CopySnapshot") && testServiceId(s, "EC2")) .build(), RuntimeClientPlugin.builder() .withConventions(AwsDependency.MACHINELEARNING_MIDDLEWARE.dependency, "PredictEndpoint", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> o.getId().getName().equals("Predict") + .operationPredicate((m, s, o) -> o.getId().getName(s).equals("Predict") && testServiceId(s, "Machine Learning")) .build(), RuntimeClientPlugin.builder() .withConventions(AwsDependency.ROUTE53_MIDDLEWARE.dependency, "ChangeResourceRecordSets", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> o.getId().getName().equals("ChangeResourceRecordSets") + .operationPredicate((m, s, o) -> o.getId().getName(s).equals("ChangeResourceRecordSets") && testServiceId(s, "Route 53")) .build(), RuntimeClientPlugin.builder() @@ -92,19 +92,19 @@ && testServiceId(s, "Route 53")) RuntimeClientPlugin.builder() .withConventions(AwsDependency.SQS_MIDDLEWARE.dependency, "SendMessage", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> o.getId().getName().equals("SendMessage") + .operationPredicate((m, s, o) -> o.getId().getName(s).equals("SendMessage") && testServiceId(s, "SQS")) .build(), RuntimeClientPlugin.builder() .withConventions(AwsDependency.SQS_MIDDLEWARE.dependency, "SendMessageBatch", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> o.getId().getName().equals("SendMessageBatch") + .operationPredicate((m, s, o) -> o.getId().getName(s).equals("SendMessageBatch") && testServiceId(s, "SQS")) .build(), RuntimeClientPlugin.builder() .withConventions(AwsDependency.SQS_MIDDLEWARE.dependency, "ReceiveMessage", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> o.getId().getName().equals("ReceiveMessage") + .operationPredicate((m, s, o) -> o.getId().getName(s).equals("ReceiveMessage") && testServiceId(s, "SQS")) .build(), RuntimeClientPlugin.builder() diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddCrossRegionCopyingPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddCrossRegionCopyingPlugin.java index 4d246faa47a0..cc3faa8e8109 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddCrossRegionCopyingPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddCrossRegionCopyingPlugin.java @@ -43,13 +43,13 @@ public List getClientPlugins() { RuntimeClientPlugin.builder() .withConventions(AwsDependency.RDS_MIDDLEWARE.dependency, "CrossRegionPresignedUrl", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> RDS_PRESIGNED_URL_OPERATIONS.contains(o.getId().getName()) + .operationPredicate((m, s, o) -> RDS_PRESIGNED_URL_OPERATIONS.contains(o.getId().getName(s)) && testServiceId(s, "RDS")) .build(), RuntimeClientPlugin.builder() .withConventions(AwsDependency.RDS_MIDDLEWARE.dependency, "CrossRegionPresignedUrl", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> SHARED_PRESIGNED_URL_OPERATIONS.contains(o.getId().getName()) + .operationPredicate((m, s, o) -> SHARED_PRESIGNED_URL_OPERATIONS.contains(o.getId().getName(s)) && (testServiceId(s, "RDS") || testServiceId(s, "DocDB") || testServiceId(s, "Neptune"))) .build() ); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java index 5e06629476ed..92a3c091931e 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java @@ -127,7 +127,7 @@ public List getClientPlugins() { .withConventions(AwsDependency.S3_MIDDLEWARE.dependency, "throw200Exceptions", HAS_MIDDLEWARE) .operationPredicate( - (m, s, o) -> EXCEPTIONS_OF_200_OPERATIONS.contains(o.getId().getName()) + (m, s, o) -> EXCEPTIONS_OF_200_OPERATIONS.contains(o.getId().getName(s)) && testServiceId(s)) .build(), RuntimeClientPlugin.builder() @@ -143,7 +143,7 @@ && testServiceId(s)) RuntimeClientPlugin.builder() .withConventions(AwsDependency.LOCATION_CONSTRAINT.dependency, "LocationConstraint", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> o.getId().getName().equals("CreateBucket") + .operationPredicate((m, s, o) -> o.getId().getName(s).equals("CreateBucket") && testServiceId(s)) .build(), /** @@ -158,13 +158,13 @@ && testServiceId(s)) RuntimeClientPlugin.builder() .withConventions(AwsDependency.BUCKET_ENDPOINT_MIDDLEWARE.dependency, "BucketEndpoint", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> !NON_BUCKET_ENDPOINT_OPERATIONS.contains(o.getId().getName()) + .operationPredicate((m, s, o) -> !NON_BUCKET_ENDPOINT_OPERATIONS.contains(o.getId().getName(s)) && testServiceId(s)) .build(), RuntimeClientPlugin.builder() .withConventions(AwsDependency.BODY_CHECKSUM.dependency, "ApplyMd5BodyChecksum", HAS_MIDDLEWARE) - .operationPredicate((m, s, o) -> S3_MD5_OPERATIONS.contains(o.getId().getName()) + .operationPredicate((m, s, o) -> S3_MD5_OPERATIONS.contains(o.getId().getName(s)) && testServiceId(s)) .build() ); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3ControlDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3ControlDependency.java index d6b1cf3eae31..ef86fa73f889 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3ControlDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3ControlDependency.java @@ -52,7 +52,7 @@ public List getClientPlugins() { "ProcessArnables", HAS_MIDDLEWARE ) - .operationPredicate((m, s, o) -> isS3Control(s) && isArnableOperation(o)) + .operationPredicate((m, s, o) -> isS3Control(s) && isArnableOperation(o, s)) .build(), RuntimeClientPlugin.builder() .withConventions( @@ -60,7 +60,7 @@ public List getClientPlugins() { "RedirectFromPostId", HAS_MIDDLEWARE ) - .operationPredicate((m, s, o) -> isS3Control(s) && !isArnableOperation(o)) + .operationPredicate((m, s, o) -> isS3Control(s) && !isArnableOperation(o, s)) .build()); } @@ -70,9 +70,10 @@ public Model preprocessModel(PluginContext context, TypeScriptSettings settings) if (!isS3Control(settings.getService(model))) { return model; } + ServiceShape serviceShape = model.expectShape(settings.getService(), ServiceShape.class); return ModelTransformer.create().mapShapes(model, shape -> { Optional modified = shape.asMemberShape() - .filter(memberShape -> memberShape.getTarget().getName().equals("AccountId")) + .filter(memberShape -> memberShape.getTarget().getName(serviceShape).equals("AccountId")) .filter(memberShape -> model.expectShape(memberShape.getTarget()).isStringShape()) .filter(memberShape -> memberShape.isRequired()) .map(memberShape -> Shape.shapeToBuilder(memberShape).removeTrait(RequiredTrait.ID).build()); @@ -85,8 +86,8 @@ private static boolean isS3Control(ServiceShape service) { return serviceId.equals("S3 Control"); } - private static boolean isArnableOperation(OperationShape operation) { - String operationName = operation.getId().getName(); + private static boolean isArnableOperation(OperationShape operation, ServiceShape serviceShape) { + String operationName = operation.getId().getName(serviceShape); return !operationName.equals("CreateBucket") && !operationName.equals("ListRegionalBuckets"); } } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java index 110c9e67ca55..383ed7163400 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java @@ -19,6 +19,7 @@ import software.amazon.smithy.aws.traits.protocols.Ec2QueryTrait; import software.amazon.smithy.codegen.core.SymbolReference; import software.amazon.smithy.model.shapes.OperationShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.shapes.StructureShape; @@ -134,8 +135,9 @@ protected void serializeInputDocument( writer.write("...$L,", inputStructure.accept(new QueryMemberSerVisitor(context, "input", Format.DATE_TIME))); // Set the protocol required values. - writer.write("Action: $S,", operation.getId().getName()); - writer.write("Version: $S,", context.getService().getVersion()); + ServiceShape serviceShape = context.getService(); + writer.write("Action: $S,", operation.getId().getName(serviceShape)); + writer.write("Version: $S,", serviceShape.getVersion()); }); } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java index c9a707f2bf01..791802662f0c 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java @@ -76,7 +76,7 @@ public void writeAdditionalFiles( TopDownIndex topDownIndex = TopDownIndex.of(model); OperationShape firstOperation = topDownIndex.getContainedOperations(service).iterator().next(); - String operationName = firstOperation.getId().getName(); + String operationName = firstOperation.getId().getName(service); resource = resource.replaceAll(Pattern.quote("${commandName}"), operationName); resource = resource.replaceAll(Pattern.quote("${operationName}"), operationName.substring(0, 1).toLowerCase() + operationName.substring(1)); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java index 9e9a36fca5c1..c94b1f0f3142 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java @@ -26,6 +26,7 @@ import software.amazon.smithy.model.neighbor.Walker; import software.amazon.smithy.model.shapes.MemberShape; import software.amazon.smithy.model.shapes.OperationShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeVisitor; import software.amazon.smithy.model.traits.IdempotencyTokenTrait; @@ -178,8 +179,9 @@ static boolean generateUndefinedQueryInputBody(GenerationContext context, Operat // Set the form encoded string. writer.openBlock("const body = buildFormUrlencodedString({", "});", () -> { // Set the protocol required values. - writer.write("Action: $S,", operation.getId().getName()); - writer.write("Version: $S,", context.getService().getVersion()); + ServiceShape serviceShape = context.getService(); + writer.write("Action: $S,", operation.getId().getName(serviceShape)); + writer.write("Version: $S,", serviceShape.getVersion()); }); return true; diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java index 4a0700f76e92..952cc827c8d2 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java @@ -19,6 +19,7 @@ import software.amazon.smithy.aws.traits.protocols.AwsQueryTrait; import software.amazon.smithy.codegen.core.SymbolReference; import software.amazon.smithy.model.shapes.OperationShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.shapes.StructureShape; @@ -134,8 +135,9 @@ protected void serializeInputDocument( writer.write("...$L,", inputStructure.accept(new QueryMemberSerVisitor(context, "input", Format.DATE_TIME))); // Set the protocol required values. - writer.write("Action: $S,", operation.getId().getName()); - writer.write("Version: $S,", context.getService().getVersion()); + ServiceShape serviceShape = context.getService(); + writer.write("Action: $S,", operation.getId().getName(serviceShape)); + writer.write("Version: $S,", serviceShape.getVersion()); }); } @@ -160,7 +162,7 @@ protected void deserializeOutputDocument( ) { TypeScriptWriter writer = context.getWriter(); - String dataSource = "data." + operation.getId().getName() + "Result"; + String dataSource = "data." + operation.getId().getName(context.getService()) + "Result"; writer.write("contents = $L;", outputStructure.accept(new XmlMemberDeserVisitor(context, dataSource, Format.DATE_TIME))); } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java index 9b0d7b634f70..c3704405ed75 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java @@ -24,6 +24,7 @@ import software.amazon.smithy.model.knowledge.HttpBinding.Location; import software.amazon.smithy.model.shapes.MemberShape; import software.amazon.smithy.model.shapes.OperationShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.shapes.StructureShape; @@ -153,6 +154,7 @@ protected void serializeInputDocument( return; } + ServiceShape serviceShape = context.getService(); SymbolProvider symbolProvider = context.getSymbolProvider(); ShapeId inputShapeId = documentBindings.get(0).getMember().getContainer(); @@ -160,11 +162,11 @@ protected void serializeInputDocument( writer.write("body = \"\";"); writer.addImport("XmlNode", "__XmlNode", "@aws-sdk/xml-builder"); - writer.write("const bodyNode = new __XmlNode($S);", inputShapeId.getName()); + writer.write("const bodyNode = new __XmlNode($S);", inputShapeId.getName(serviceShape)); // Add @xmlNamespace value of the service to the root node, // fall back to one from the input shape. - boolean serviceXmlns = AwsProtocolUtils.writeXmlNamespace(context, context.getService(), "bodyNode"); + boolean serviceXmlns = AwsProtocolUtils.writeXmlNamespace(context, serviceShape, "bodyNode"); if (!serviceXmlns) { StructureShape inputShape = context.getModel().expectShape(inputShapeId, StructureShape.class); AwsProtocolUtils.writeXmlNamespace(context, inputShape, "bodyNode"); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java index c610a5a7f54a..15280caf69a6 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java @@ -17,6 +17,7 @@ import java.util.Set; import software.amazon.smithy.model.shapes.OperationShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.StructureShape; import software.amazon.smithy.model.traits.TimestampFormatTrait.Format; @@ -88,7 +89,8 @@ protected void writeDefaultHeaders(GenerationContext context, OperationShape ope // AWS JSON RPC protocols use a combination of the service and operation shape names, // separated by a '.' character, for the target header. TypeScriptWriter writer = context.getWriter(); - String target = context.getService().getId().getName() + "." + operation.getId().getName(); + ServiceShape serviceShape = context.getService(); + String target = serviceShape.getId().getName(serviceShape) + "." + operation.getId().getName(serviceShape); writer.write("'x-amz-target': $S,", target); } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonShapeSerVisitor.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonShapeSerVisitor.java index 4193dcb8b851..18414e15c172 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonShapeSerVisitor.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonShapeSerVisitor.java @@ -23,6 +23,7 @@ import software.amazon.smithy.model.shapes.DocumentShape; import software.amazon.smithy.model.shapes.MapShape; import software.amazon.smithy.model.shapes.MemberShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.StructureShape; import software.amazon.smithy.model.shapes.UnionShape; @@ -152,9 +153,10 @@ public void serializeStructure(GenerationContext context, StructureShape shape) public void serializeUnion(GenerationContext context, UnionShape shape) { TypeScriptWriter writer = context.getWriter(); Model model = context.getModel(); + ServiceShape serviceShape = context.getService(); // Visit over the union type, then get the right serialization for the member. - writer.openBlock("return $L.visit(input, {", "});", shape.getId().getName(), () -> { + writer.openBlock("return $L.visit(input, {", "});", shape.getId().getName(serviceShape), () -> { // Use a TreeMap to sort the members. Map members = new TreeMap<>(shape.getAllMembers()); members.forEach((memberName, memberShape) -> { diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/QueryShapeSerVisitor.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/QueryShapeSerVisitor.java index 093306957b81..4d1feb440880 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/QueryShapeSerVisitor.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/QueryShapeSerVisitor.java @@ -21,6 +21,7 @@ import software.amazon.smithy.model.shapes.DocumentShape; import software.amazon.smithy.model.shapes.MapShape; import software.amazon.smithy.model.shapes.MemberShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.StructureShape; import software.amazon.smithy.model.shapes.UnionShape; @@ -272,12 +273,13 @@ protected boolean isFlattenedMember(GenerationContext context, MemberShape membe @Override protected void serializeUnion(GenerationContext context, UnionShape shape) { TypeScriptWriter writer = context.getWriter(); + ServiceShape serviceShape = context.getService(); // Set up a location to store the entry pair. writer.write("const entries: any = {};"); // Visit over the union type, then get the right serialization for the member. - writer.openBlock("$L.visit(input, {", "});", shape.getId().getName(), () -> { + writer.openBlock("$L.visit(input, {", "});", shape.getId().getName(serviceShape), () -> { shape.getAllMembers().forEach((memberName, memberShape) -> { writer.openBlock("$L: value => {", "},", memberName, () -> { serializeNamedMember(context, memberName, memberShape, "value"); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlMemberSerVisitor.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlMemberSerVisitor.java index 4ee8aaadfaba..b80fdf436618 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlMemberSerVisitor.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlMemberSerVisitor.java @@ -49,9 +49,11 @@ * @see Smithy XML traits. */ final class XmlMemberSerVisitor extends DocumentMemberSerVisitor { + private final GenerationContext context; XmlMemberSerVisitor(GenerationContext context, String dataSource, Format defaultTimestampFormat) { super(context, dataSource, defaultTimestampFormat); + this.context = context; } @Override @@ -112,7 +114,7 @@ String getAsXmlText(Shape shape, String dataSource) { // Handle the @xmlName trait for the shape itself. String nodeName = shape.getTrait(XmlNameTrait.class) .map(XmlNameTrait::getValue) - .orElse(shape.getId().getName()); + .orElse(shape.getId().getName(context.getService())); TypeScriptWriter writer = getContext().getWriter(); writer.addImport("XmlNode", "__XmlNode", "@aws-sdk/xml-builder"); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlShapeSerVisitor.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlShapeSerVisitor.java index cc4cbfdfa967..6ded4d6f5ff1 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlShapeSerVisitor.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlShapeSerVisitor.java @@ -23,6 +23,7 @@ import software.amazon.smithy.model.shapes.DocumentShape; import software.amazon.smithy.model.shapes.MapShape; import software.amazon.smithy.model.shapes.MemberShape; +import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.model.shapes.Shape; import software.amazon.smithy.model.shapes.StructureShape; import software.amazon.smithy.model.shapes.UnionShape; @@ -183,12 +184,13 @@ protected void serializeMap(GenerationContext context, MapShape shape) { @Override protected void serializeStructure(GenerationContext context, StructureShape shape) { TypeScriptWriter writer = context.getWriter(); + ServiceShape serviceShape = context.getService(); writer.addImport("XmlNode", "__XmlNode", "@aws-sdk/xml-builder"); // Handle the @xmlName trait for the structure itself. String nodeName = shape.getTrait(XmlNameTrait.class) .map(XmlNameTrait::getValue) - .orElse(shape.getId().getName()); + .orElse(shape.getId().getName(serviceShape)); // Create the structure's node. writer.write("const bodyNode = new __XmlNode($S);", nodeName); @@ -298,19 +300,20 @@ private boolean serializationReturnsArray(Shape shape) { @Override protected void serializeUnion(GenerationContext context, UnionShape shape) { TypeScriptWriter writer = context.getWriter(); + ServiceShape serviceShape = context.getService(); writer.addImport("XmlNode", "__XmlNode", "@aws-sdk/xml-builder"); writer.addImport("XmlText", "__XmlText", "@aws-sdk/xml-builder"); // Handle the @xmlName trait for the union itself. String nodeName = shape.getTrait(XmlNameTrait.class) .map(XmlNameTrait::getValue) - .orElse(shape.getId().getName()); + .orElse(shape.getId().getName(serviceShape)); // Create the union's node. writer.write("const bodyNode = new __XmlNode($S);", nodeName); // Visit over the union type, then get the right serialization for the member. - writer.openBlock("$L.visit(input, {", "});", shape.getId().getName(), () -> { + writer.openBlock("$L.visit(input, {", "});", shape.getId().getName(serviceShape), () -> { Map members = shape.getAllMembers(); members.forEach((memberName, memberShape) -> { writer.openBlock("$L: value => {", "},", memberName, () -> {