Skip to content

Fix/extra parens #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/gen_elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
fail-fast: false
matrix:
elixir: ["1.13.4"]
erlang: ["25.0.4"]
elixir: ["1.18.3"]
erlang: ["26"]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -51,4 +51,4 @@ jobs:
run: |
mix deps.get
mix test
working-directory: aws-beam/aws-elixir
working-directory: aws-beam/aws-elixir
8 changes: 4 additions & 4 deletions .github/workflows/gen_erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest]
elixir: ["1.13.4"]
erlang: ["25.0.4"]
rebar3: ['3.20.0']
elixir: ["1.18.3"]
erlang: ["26"]
rebar3: ["3.25.0"]
runs-on: ${{ matrix.platform }}
services:
ddb:
image: amazon/dynamodb-local:1.21.0
ports:
- 8000:8000
s3mock:
image: adobe/s3mock:2.11.0
image: adobe/s3mock:4.6.0
ports:
- 9090:9090
steps:
Expand Down
14 changes: 9 additions & 5 deletions lib/aws_codegen/types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,24 @@ defmodule AWS.CodeGen.Types do
%Shape{type: "structure"} ->
type =
"#{AWS.CodeGen.Name.to_snake_case(String.replace(shape_name, ~r/com\.amazonaws\.[^#]+#/, ""))}"
|> AWS.CodeGen.Util.maybe_add_parens()

if reserved_type(type) do
"#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}()"
"#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}"
else
"#{type}()"
"#{type}"
end

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

if reserved_type(type) do
"list(#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}())"
"list(#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type})"
else
"list(#{type}())"
"list(#{type})"
end

nil ->
Expand Down
8 changes: 8 additions & 0 deletions lib/aws_codegen/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ defmodule AWS.CodeGen.Util do
|> Enum.reverse()
end
end

def maybe_add_parens(string) do
if String.ends_with?(string, "()") do
string
else
string <> "()"
end
end
end
18 changes: 9 additions & 9 deletions test/aws_codegen_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ defmodule AWS.CodeGenTest do

put_audit_events_request() :: %{
optional(\"externalId\") => String.t(),
required(\"auditEvents\") => list(audit_event()()),
required(\"auditEvents\") => list(audit_event()),
required(\"channelArn\") => String.t()
}

Expand All @@ -183,8 +183,8 @@ defmodule AWS.CodeGenTest do
## Example:

put_audit_events_response() :: %{
required(\"failed\") => list(result_error_entry()()),
required(\"successful\") => list(audit_event_result_entry()())
required(\"failed\") => list(result_error_entry()),
required(\"successful\") => list(audit_event_result_entry())
}

\"\"\"
Expand Down Expand Up @@ -409,7 +409,7 @@ defmodule AWS.CodeGenTest do

put_audit_events_request() :: %{
optional(\"externalId\") => String.t(),
required(\"auditEvents\") => list(audit_event()()),
required(\"auditEvents\") => list(audit_event()),
required(\"channelArn\") => String.t()
}

Expand All @@ -421,8 +421,8 @@ defmodule AWS.CodeGenTest do
## Example:

put_audit_events_response() :: %{
required(\"failed\") => list(result_error_entry()()),
required(\"successful\") => list(audit_event_result_entry()())
required(\"failed\") => list(result_error_entry()),
required(\"successful\") => list(audit_event_result_entry())
}

\"\"\"
Expand Down Expand Up @@ -653,7 +653,7 @@ defmodule AWS.CodeGenTest do

put_audit_events_request() :: %{
optional(\"externalId\") => String.t(),
required(\"auditEvents\") => list(audit_event()()),
required(\"auditEvents\") => list(audit_event()),
required(\"channelArn\") => String.t()
}

Expand All @@ -665,8 +665,8 @@ defmodule AWS.CodeGenTest do
## Example:

put_audit_events_response() :: %{
required(\"failed\") => list(result_error_entry()()),
required(\"successful\") => list(audit_event_result_entry()())
required(\"failed\") => list(result_error_entry()),
required(\"successful\") => list(audit_event_result_entry())
}

\"\"\"
Expand Down
Loading
Loading