File tree Expand file tree Collapse file tree 4 files changed +101
-0
lines changed
smithy-typescript-codegen/src/test
java/software/amazon/smithy/typescript/codegen
resources/software/amazon/smithy/typescript/codegen Expand file tree Collapse file tree 4 files changed +101
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,39 @@ public void callsFilterInUnionWithoutSensitiveData() {
179
179
+ " }\n " );
180
180
}
181
181
182
+ @ Test
183
+ public void callsFilterInUnionWithStructure () {
184
+ testStructureCodegen ("test-union-with-structure.smithy" ,
185
+ " export const filterSensitiveLog = (obj: TestUnion): any => {\n "
186
+ + " if (obj.fooUser !== undefined) return {fooUser:\n "
187
+ + " User.filterSensitiveLog(obj.fooUser)\n "
188
+ + " };\n "
189
+ + " if (obj.$unknown !== undefined) return {[obj.$unknown[0]]: 'UNKNOWN'};\n "
190
+ + " }\n " );
191
+ }
192
+
193
+ @ Test
194
+ public void callsFilterInUnionWithList () {
195
+ testStructureCodegen ("test-union-with-list.smithy" ,
196
+ " export const filterSensitiveLog = (obj: TestUnion): any => {\n "
197
+ + " if (obj.list !== undefined) return {list:\n "
198
+ + " obj.list\n "
199
+ + " };\n "
200
+ + " if (obj.$unknown !== undefined) return {[obj.$unknown[0]]: 'UNKNOWN'};\n "
201
+ + " }\n " );
202
+ }
203
+
204
+ @ Test
205
+ public void callsFilterInUnionWithMap () {
206
+ testStructureCodegen ("test-union-with-map.smithy" ,
207
+ " export const filterSensitiveLog = (obj: TestUnion): any => {\n "
208
+ + " if (obj.map !== undefined) return {map:\n "
209
+ + " obj.map\n "
210
+ + " };\n "
211
+ + " if (obj.$unknown !== undefined) return {[obj.$unknown[0]]: 'UNKNOWN'};\n "
212
+ + " }\n " );
213
+ }
214
+
182
215
@ Test
183
216
public void filtersStreamingUnion () {
184
217
testStructureCodegen ("test-streaming-union.smithy" ,
Original file line number Diff line number Diff line change
1
+ namespace smithy.example
2
+
3
+ service Example {
4
+ version : " 1.0.0" ,
5
+ operations : [GetFoo ]
6
+ }
7
+
8
+ operation GetFoo {
9
+ input : GetFooInput
10
+ }
11
+
12
+ structure GetFooInput {
13
+ foo : TestUnion
14
+ }
15
+
16
+ union TestUnion {
17
+ list : NamesList
18
+ }
19
+
20
+ list NamesList {
21
+ member : String
22
+ }
Original file line number Diff line number Diff line change
1
+ namespace smithy.example
2
+
3
+ service Example {
4
+ version : " 1.0.0" ,
5
+ operations : [GetFoo ]
6
+ }
7
+
8
+ operation GetFoo {
9
+ input : GetFooInput
10
+ }
11
+
12
+ structure GetFooInput {
13
+ foo : TestUnion
14
+ }
15
+
16
+ union TestUnion {
17
+ map : NamesMap
18
+ }
19
+
20
+ map NamesMap {
21
+ key : String ,
22
+ value : String
23
+ }
Original file line number Diff line number Diff line change
1
+ namespace smithy.example
2
+
3
+ service Example {
4
+ version : " 1.0.0" ,
5
+ operations : [GetFoo ]
6
+ }
7
+
8
+ operation GetFoo {
9
+ input : GetFooInput
10
+ }
11
+
12
+ structure GetFooInput {
13
+ foo : TestUnion
14
+ }
15
+
16
+ union TestUnion {
17
+ fooUser : User
18
+ }
19
+
20
+ structure User {
21
+ firstname : String ,
22
+ lastname : String
23
+ }
You can’t perform that action at this time.
0 commit comments