Skip to content

Commit c9dc940

Browse files
committed
chore: switch to using maybe_add_parens/1 and update tests
1 parent bc6571a commit c9dc940

File tree

3 files changed

+58
-54
lines changed

3 files changed

+58
-54
lines changed

lib/aws_codegen/types.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,24 @@ defmodule AWS.CodeGen.Types do
103103
%Shape{type: "structure"} ->
104104
type =
105105
"#{AWS.CodeGen.Name.to_snake_case(String.replace(shape_name, ~r/com\.amazonaws\.[^#]+#/, ""))}"
106+
|> AWS.CodeGen.Util.maybe_add_parens()
106107

107108
if reserved_type(type) do
108-
"#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}()"
109+
"#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}"
109110
else
110-
"#{type}()"
111+
"#{type}"
111112
end
112113

113114
%Shape{type: "list", member: member} ->
114-
type = "#{shape_to_type(context, member["target"], module_name, all_shapes)}"
115+
# this change alone gets us down to 1595
116+
type =
117+
"#{shape_to_type(context, member["target"], module_name, all_shapes)}"
118+
|> AWS.CodeGen.Util.maybe_add_parens()
115119

116120
if reserved_type(type) do
117-
"list(#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}())"
121+
"list(#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type})"
118122
else
119-
"list(#{type}())"
123+
"list(#{type})"
120124
end
121125

122126
nil ->

test/aws_codegen_test.exs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ defmodule AWS.CodeGenTest do
171171
172172
put_audit_events_request() :: %{
173173
optional(\"externalId\") => String.t(),
174-
required(\"auditEvents\") => list(audit_event()()),
174+
required(\"auditEvents\") => list(audit_event()),
175175
required(\"channelArn\") => String.t()
176176
}
177177
@@ -183,8 +183,8 @@ defmodule AWS.CodeGenTest do
183183
## Example:
184184
185185
put_audit_events_response() :: %{
186-
required(\"failed\") => list(result_error_entry()()),
187-
required(\"successful\") => list(audit_event_result_entry()())
186+
required(\"failed\") => list(result_error_entry()),
187+
required(\"successful\") => list(audit_event_result_entry())
188188
}
189189
190190
\"\"\"
@@ -409,7 +409,7 @@ defmodule AWS.CodeGenTest do
409409
410410
put_audit_events_request() :: %{
411411
optional(\"externalId\") => String.t(),
412-
required(\"auditEvents\") => list(audit_event()()),
412+
required(\"auditEvents\") => list(audit_event()),
413413
required(\"channelArn\") => String.t()
414414
}
415415
@@ -421,8 +421,8 @@ defmodule AWS.CodeGenTest do
421421
## Example:
422422
423423
put_audit_events_response() :: %{
424-
required(\"failed\") => list(result_error_entry()()),
425-
required(\"successful\") => list(audit_event_result_entry()())
424+
required(\"failed\") => list(result_error_entry()),
425+
required(\"successful\") => list(audit_event_result_entry())
426426
}
427427
428428
\"\"\"
@@ -653,7 +653,7 @@ defmodule AWS.CodeGenTest do
653653
654654
put_audit_events_request() :: %{
655655
optional(\"externalId\") => String.t(),
656-
required(\"auditEvents\") => list(audit_event()()),
656+
required(\"auditEvents\") => list(audit_event()),
657657
required(\"channelArn\") => String.t()
658658
}
659659
@@ -665,8 +665,8 @@ defmodule AWS.CodeGenTest do
665665
## Example:
666666
667667
put_audit_events_response() :: %{
668-
required(\"failed\") => list(result_error_entry()()),
669-
required(\"successful\") => list(audit_event_result_entry()())
668+
required(\"failed\") => list(result_error_entry()),
669+
required(\"successful\") => list(audit_event_result_entry())
670670
}
671671
672672
\"\"\"

test/fixtures/generated/data_exchange.ex

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ defmodule AWS.DataExchange do
111111
## Example:
112112
113113
scope_details() :: %{
114-
"LakeFormationTagPolicies" => list(lake_formation_tag_policy_details()()),
115-
"RedshiftDataShares" => list(redshift_data_share_details()()),
116-
"S3DataAccesses" => list(s3_data_access_details()())
114+
"LakeFormationTagPolicies" => list(lake_formation_tag_policy_details()),
115+
"RedshiftDataShares" => list(redshift_data_share_details()),
116+
"S3DataAccesses" => list(s3_data_access_details())
117117
}
118118
119119
"""
@@ -208,7 +208,7 @@ defmodule AWS.DataExchange do
208208
## Example:
209209
210210
list_received_data_grants_request() :: %{
211-
optional("AcceptanceState") => list(String.t()()),
211+
optional("AcceptanceState") => list(String.t()),
212212
optional("MaxResults") => integer(),
213213
optional("NextToken") => String.t()
214214
}
@@ -221,7 +221,7 @@ defmodule AWS.DataExchange do
221221
## Example:
222222
223223
list_data_sets_response() :: %{
224-
optional("DataSets") => list(data_set_entry()()),
224+
optional("DataSets") => list(data_set_entry()),
225225
optional("NextToken") => String.t()
226226
}
227227
@@ -236,7 +236,7 @@ defmodule AWS.DataExchange do
236236
"DataSetId" => String.t(),
237237
"Encryption" => export_server_side_encryption(),
238238
"EventActionArn" => String.t(),
239-
"RevisionDestinations" => list(revision_destination_entry()())
239+
"RevisionDestinations" => list(revision_destination_entry())
240240
}
241241
242242
"""
@@ -250,7 +250,7 @@ defmodule AWS.DataExchange do
250250
optional("Arn") => String.t(),
251251
optional("CreatedAt") => non_neg_integer(),
252252
optional("Details") => response_details(),
253-
optional("Errors") => list(job_error()()),
253+
optional("Errors") => list(job_error()),
254254
optional("Id") => String.t(),
255255
optional("State") => String.t(),
256256
optional("Type") => String.t(),
@@ -300,7 +300,7 @@ defmodule AWS.DataExchange do
300300
## Example:
301301
302302
list_received_data_grants_response() :: %{
303-
"DataGrantSummaries" => list(received_data_grant_summaries_entry()()),
303+
"DataGrantSummaries" => list(received_data_grant_summaries_entry()),
304304
"NextToken" => String.t()
305305
}
306306
@@ -475,7 +475,7 @@ defmodule AWS.DataExchange do
475475
## Example:
476476
477477
list_jobs_response() :: %{
478-
optional("Jobs") => list(job_entry()()),
478+
optional("Jobs") => list(job_entry()),
479479
optional("NextToken") => String.t()
480480
}
481481
@@ -499,7 +499,7 @@ defmodule AWS.DataExchange do
499499
## Example:
500500
501501
untag_resource_request() :: %{
502-
required("TagKeys") => list(String.t()())
502+
required("TagKeys") => list(String.t())
503503
}
504504
505505
"""
@@ -510,8 +510,8 @@ defmodule AWS.DataExchange do
510510
## Example:
511511
512512
database_l_f_tag_policy_and_permissions() :: %{
513-
"Expression" => list(l_f_tag()()),
514-
"Permissions" => list(String.t()())
513+
"Expression" => list(l_f_tag()),
514+
"Permissions" => list(String.t())
515515
}
516516
517517
"""
@@ -689,7 +689,7 @@ defmodule AWS.DataExchange do
689689
690690
list_data_set_revisions_response() :: %{
691691
optional("NextToken") => String.t(),
692-
optional("Revisions") => list(revision_entry()())
692+
optional("Revisions") => list(revision_entry())
693693
}
694694
695695
"""
@@ -782,8 +782,8 @@ defmodule AWS.DataExchange do
782782
## Example:
783783
784784
table_l_f_tag_policy_and_permissions() :: %{
785-
"Expression" => list(l_f_tag()()),
786-
"Permissions" => list(String.t()())
785+
"Expression" => list(l_f_tag()),
786+
"Permissions" => list(String.t())
787787
}
788788
789789
"""
@@ -794,7 +794,7 @@ defmodule AWS.DataExchange do
794794
## Example:
795795
796796
export_assets_to_s3_request_details() :: %{
797-
"AssetDestinations" => list(asset_destination_entry()()),
797+
"AssetDestinations" => list(asset_destination_entry()),
798798
"DataSetId" => String.t(),
799799
"Encryption" => export_server_side_encryption(),
800800
"RevisionId" => String.t()
@@ -845,7 +845,7 @@ defmodule AWS.DataExchange do
845845
## Example:
846846
847847
export_assets_to_s3_response_details() :: %{
848-
"AssetDestinations" => list(asset_destination_entry()()),
848+
"AssetDestinations" => list(asset_destination_entry()),
849849
"DataSetId" => String.t(),
850850
"Encryption" => export_server_side_encryption(),
851851
"RevisionId" => String.t()
@@ -859,7 +859,7 @@ defmodule AWS.DataExchange do
859859
## Example:
860860
861861
list_revision_assets_response() :: %{
862-
optional("Assets") => list(asset_entry()()),
862+
optional("Assets") => list(asset_entry()),
863863
optional("NextToken") => String.t()
864864
}
865865
@@ -872,7 +872,7 @@ defmodule AWS.DataExchange do
872872
873873
details() :: %{
874874
"ImportAssetFromSignedUrlJobErrorDetails" => import_asset_from_signed_url_job_error_details(),
875-
"ImportAssetsFromS3JobErrorDetails" => list(asset_source_entry()())
875+
"ImportAssetsFromS3JobErrorDetails" => list(asset_source_entry())
876876
}
877877
878878
"""
@@ -930,7 +930,7 @@ defmodule AWS.DataExchange do
930930
## Example:
931931
932932
schema_change_request_details() :: %{
933-
"Changes" => list(schema_change_details()()),
933+
"Changes" => list(schema_change_details()),
934934
"SchemaChangeAt" => non_neg_integer()
935935
}
936936
@@ -963,7 +963,7 @@ defmodule AWS.DataExchange do
963963
## Example:
964964
965965
database_l_f_tag_policy() :: %{
966-
"Expression" => list(l_f_tag()())
966+
"Expression" => list(l_f_tag())
967967
}
968968
969969
"""
@@ -975,9 +975,9 @@ defmodule AWS.DataExchange do
975975
976976
s3_data_access_asset() :: %{
977977
"Bucket" => String.t(),
978-
"KeyPrefixes" => list(String.t()()),
979-
"Keys" => list(String.t()()),
980-
"KmsKeysToGrant" => list(kms_key_to_grant()()),
978+
"KeyPrefixes" => list(String.t()),
979+
"Keys" => list(String.t()),
980+
"KmsKeysToGrant" => list(kms_key_to_grant()),
981981
"S3AccessPointAlias" => String.t(),
982982
"S3AccessPointArn" => String.t()
983983
}
@@ -1012,7 +1012,7 @@ defmodule AWS.DataExchange do
10121012
## Example:
10131013
10141014
table_l_f_tag_policy() :: %{
1015-
"Expression" => list(l_f_tag()())
1015+
"Expression" => list(l_f_tag())
10161016
}
10171017
10181018
"""
@@ -1100,9 +1100,9 @@ defmodule AWS.DataExchange do
11001100
11011101
s3_data_access_asset_source_entry() :: %{
11021102
"Bucket" => String.t(),
1103-
"KeyPrefixes" => list(String.t()()),
1104-
"Keys" => list(String.t()()),
1105-
"KmsKeysToGrant" => list(kms_key_to_grant()())
1103+
"KeyPrefixes" => list(String.t()),
1104+
"Keys" => list(String.t()),
1105+
"KmsKeysToGrant" => list(kms_key_to_grant())
11061106
}
11071107
11081108
"""
@@ -1251,8 +1251,8 @@ defmodule AWS.DataExchange do
12511251
## Example:
12521252
12531253
s3_data_access_details() :: %{
1254-
"KeyPrefixes" => list(String.t()()),
1255-
"Keys" => list(String.t()())
1254+
"KeyPrefixes" => list(String.t()),
1255+
"Keys" => list(String.t())
12561256
}
12571257
12581258
"""
@@ -1300,7 +1300,7 @@ defmodule AWS.DataExchange do
13001300
## Example:
13011301
13021302
import_assets_from_s3_response_details() :: %{
1303-
"AssetSources" => list(asset_source_entry()()),
1303+
"AssetSources" => list(asset_source_entry()),
13041304
"DataSetId" => String.t(),
13051305
"RevisionId" => String.t()
13061306
}
@@ -1322,7 +1322,7 @@ defmodule AWS.DataExchange do
13221322
## Example:
13231323
13241324
import_assets_from_redshift_data_shares_request_details() :: %{
1325-
"AssetSources" => list(redshift_data_share_asset_source_entry()()),
1325+
"AssetSources" => list(redshift_data_share_asset_source_entry()),
13261326
"DataSetId" => String.t(),
13271327
"RevisionId" => String.t()
13281328
}
@@ -1368,7 +1368,7 @@ defmodule AWS.DataExchange do
13681368
## Example:
13691369
13701370
import_assets_from_redshift_data_shares_response_details() :: %{
1371-
"AssetSources" => list(redshift_data_share_asset_source_entry()()),
1371+
"AssetSources" => list(redshift_data_share_asset_source_entry()),
13721372
"DataSetId" => String.t(),
13731373
"RevisionId" => String.t()
13741374
}
@@ -1430,7 +1430,7 @@ defmodule AWS.DataExchange do
14301430
optional("Arn") => String.t(),
14311431
optional("CreatedAt") => non_neg_integer(),
14321432
optional("Details") => response_details(),
1433-
optional("Errors") => list(job_error()()),
1433+
optional("Errors") => list(job_error()),
14341434
optional("Id") => String.t(),
14351435
optional("State") => String.t(),
14361436
optional("Type") => String.t(),
@@ -1613,7 +1613,7 @@ defmodule AWS.DataExchange do
16131613
## Example:
16141614
16151615
import_assets_from_s3_request_details() :: %{
1616-
"AssetSources" => list(asset_source_entry()()),
1616+
"AssetSources" => list(asset_source_entry()),
16171617
"DataSetId" => String.t(),
16181618
"RevisionId" => String.t()
16191619
}
@@ -1628,7 +1628,7 @@ defmodule AWS.DataExchange do
16281628
lake_formation_data_permission_asset() :: %{
16291629
"LakeFormationDataPermissionDetails" => lake_formation_data_permission_details(),
16301630
"LakeFormationDataPermissionType" => String.t(),
1631-
"Permissions" => list(String.t()()),
1631+
"Permissions" => list(String.t()),
16321632
"RoleArn" => String.t()
16331633
}
16341634
@@ -1653,7 +1653,7 @@ defmodule AWS.DataExchange do
16531653
## Example:
16541654
16551655
list_data_grants_response() :: %{
1656-
"DataGrantSummaries" => list(data_grant_summary_entry()()),
1656+
"DataGrantSummaries" => list(data_grant_summary_entry()),
16571657
"NextToken" => String.t()
16581658
}
16591659
@@ -1715,7 +1715,7 @@ defmodule AWS.DataExchange do
17151715
## Example:
17161716
17171717
list_event_actions_response() :: %{
1718-
optional("EventActions") => list(event_action_entry()()),
1718+
optional("EventActions") => list(event_action_entry()),
17191719
optional("NextToken") => String.t()
17201720
}
17211721
@@ -1749,7 +1749,7 @@ defmodule AWS.DataExchange do
17491749
"Arn" => String.t(),
17501750
"CreatedAt" => non_neg_integer(),
17511751
"Details" => response_details(),
1752-
"Errors" => list(job_error()()),
1752+
"Errors" => list(job_error()),
17531753
"Id" => String.t(),
17541754
"State" => String.t(),
17551755
"Type" => String.t(),
@@ -1875,7 +1875,7 @@ defmodule AWS.DataExchange do
18751875
export_revisions_to_s3_request_details() :: %{
18761876
"DataSetId" => String.t(),
18771877
"Encryption" => export_server_side_encryption(),
1878-
"RevisionDestinations" => list(revision_destination_entry()())
1878+
"RevisionDestinations" => list(revision_destination_entry())
18791879
}
18801880
18811881
"""

0 commit comments

Comments
 (0)