@@ -974,3 +974,91 @@ func TestValidateShapeNameMethod(t *testing.T) {
974974 })
975975 }
976976}
977+
978+ // TestRenamedUnionShapePreservesOriginalName verifies that when a union
979+ // shape is renamed (e.g. MemoryStrategyInput -> MemoryStrategyInput_) by
980+ // renameIOSuffixedShapeNames, the OriginalShapeName is preserved. The
981+ // downstream SDK code generation functions (setSDKForUnion,
982+ // setResourceForUnion, varEmptyConstructorSDKType) use OriginalShapeName
983+ // to emit correct SDK type references.
984+ func TestRenamedUnionShapePreservesOriginalName (t * testing.T ) {
985+ a := & API {
986+ name : "testapi" ,
987+ Metadata : Metadata {
988+ APIVersion : "0000-00-00" ,
989+ EndpointPrefix : "testapi" ,
990+ JSONVersion : "1.1" ,
991+ Protocol : "json" ,
992+ ServiceAbbreviation : "TestAPI" ,
993+ ServiceFullName : "Test API" ,
994+ SignatureVersion : "v4" ,
995+ },
996+ Operations : map [string ]* Operation {
997+ "CreateMemory" : {
998+ Name : "CreateMemory" ,
999+ InputRef : ShapeRef {ShapeName : "CreateMemoryInput" },
1000+ OutputRef : ShapeRef {ShapeName : "CreateMemoryOutput" },
1001+ },
1002+ },
1003+ Shapes : map [string ]* Shape {
1004+ "CreateMemoryInput" : {
1005+ ShapeName : "CreateMemoryInput" ,
1006+ Type : "structure" ,
1007+ MemberRefs : map [string ]* ShapeRef {
1008+ "Strategies" : {ShapeName : "MemoryStrategyInputList" },
1009+ },
1010+ },
1011+ "CreateMemoryOutput" : {
1012+ ShapeName : "CreateMemoryOutput" ,
1013+ Type : "structure" ,
1014+ },
1015+ "MemoryStrategyInputList" : {
1016+ ShapeName : "MemoryStrategyInputList" ,
1017+ Type : "list" ,
1018+ MemberRef : ShapeRef {ShapeName : "MemoryStrategyInput" },
1019+ },
1020+ "MemoryStrategyInput" : {
1021+ ShapeName : "MemoryStrategyInput" ,
1022+ Type : "structure" ,
1023+ RealType : "union" ,
1024+ },
1025+ },
1026+ }
1027+
1028+ // Wire up shape refs
1029+ for _ , op := range a .Operations {
1030+ op .InputRef .API = a
1031+ op .InputRef .Shape = a .Shapes [op .InputRef .ShapeName ]
1032+ op .OutputRef .API = a
1033+ op .OutputRef .Shape = a .Shapes [op .OutputRef .ShapeName ]
1034+ }
1035+ for _ , s := range a .Shapes {
1036+ s .API = a
1037+ for k := range s .MemberRefs {
1038+ ref := s .MemberRefs [k ]
1039+ ref .API = a
1040+ ref .Shape = a .Shapes [ref .ShapeName ]
1041+ s .MemberRefs [k ] = ref
1042+ }
1043+ if s .MemberRef .ShapeName != "" {
1044+ s .MemberRef .API = a
1045+ s .MemberRef .Shape = a .Shapes [s .MemberRef .ShapeName ]
1046+ }
1047+ }
1048+
1049+ unionShape := a .Shapes ["MemoryStrategyInput" ]
1050+ if unionShape .OriginalShapeName != "" {
1051+ t .Fatalf ("expected empty OriginalShapeName before rename, got %q" , unionShape .OriginalShapeName )
1052+ }
1053+
1054+ a .renameIOSuffixedShapeNames ()
1055+
1056+ // ShapeName gets underscore suffix, OriginalShapeName preserves the
1057+ // pre-rename value for downstream SDK code generation.
1058+ if unionShape .ShapeName != "MemoryStrategyInput_" {
1059+ t .Fatalf ("expected ShapeName %q after rename, got %q" , "MemoryStrategyInput_" , unionShape .ShapeName )
1060+ }
1061+ if unionShape .OriginalShapeName != "MemoryStrategyInput" {
1062+ t .Fatalf ("expected OriginalShapeName %q after rename, got %q" , "MemoryStrategyInput" , unionShape .OriginalShapeName )
1063+ }
1064+ }
0 commit comments