@@ -99,6 +99,45 @@ class UnionGeneratorTests {
99
99
contents.shouldContain(expectedGeneratedEnum)
100
100
}
101
101
102
+ @Test
103
+ fun `it renders recursive union shape` () {
104
+ val simpleUnionShapeBuilder = createUnionShapeBuilderWithMembers(
105
+ MemberShape .builder().id(" smithy.example#MyUnion\$ foo" ).target(" smithy.example#MyUnion" ).build(),
106
+ MemberShape .builder().id(" smithy.example#MyUnion\$ baz" ).target(" smithy.api#Integer" ).build(),
107
+ MemberShape .builder().id(" smithy.example#MyUnion\$ bar" )
108
+ .target(" smithy.api#PrimitiveInteger" )
109
+ .addTrait(DocumentationTrait (" Documentation for bar" ))
110
+ .build()
111
+ )
112
+ val simpleUnionShape = simpleUnionShapeBuilder.build()
113
+ val model = createModelFromShapes(simpleUnionShape)
114
+ val settings = model.defaultSettings()
115
+ val provider: SymbolProvider = SwiftCodegenPlugin .createSymbolProvider(model, settings)
116
+ val writer = SwiftWriter (" MockPackage" )
117
+
118
+ val generator = UnionGenerator (model, provider, writer, simpleUnionShape, settings)
119
+ generator.render()
120
+
121
+ val contents = writer.toString()
122
+
123
+ contents.shouldContain(SwiftWriter .staticHeader)
124
+
125
+ val expectedGeneratedEnum =
126
+ """
127
+ /// Really long multi-line Documentation for MyUnion
128
+ public indirect enum MyUnion: Swift.Equatable {
129
+ /// Really long multi-line Documentation for MyUnion
130
+ case foo(MyUnion)
131
+ case baz(Swift.Int)
132
+ /// Documentation for bar
133
+ case bar(Swift.Int)
134
+ case sdkUnknown(Swift.String)
135
+ }
136
+ """ .trimIndent()
137
+
138
+ contents.shouldContain(expectedGeneratedEnum)
139
+ }
140
+
102
141
private fun createUnionShapeBuilderWithMembers (vararg memberShapes : MemberShape ): UnionShape .Builder {
103
142
val unionShapeBuilder = UnionShape .builder()
104
143
unionShapeBuilder.id(" smithy.example#MyUnion" ).addTrait(
0 commit comments