Skip to content

Commit 7a46377

Browse files
committed
Add Atom.t() to Elixir type specs so either String.t() or Atom.t() is accepted
1 parent 03c8dfe commit 7a46377

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/aws_codegen/types.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ defmodule AWS.CodeGen.Types do
133133
end
134134

135135
# Unfortunately, gotta patch over auto-defining types that already exist in Elixir
136-
defp shape_to_type(:elixir, "String", _), do: "String.t()"
136+
defp shape_to_type(:elixir, "String", _), do: "String.t() | Atom.t()"
137137
defp shape_to_type(:erlang, "String", _), do: "string()"
138-
defp shape_to_type(:elixir, "string", _), do: "String.t()"
138+
defp shape_to_type(:elixir, "string", _), do: "String.t() | Atom.t()"
139139
defp shape_to_type(:erlang, "string", _), do: "string()"
140-
defp shape_to_type(:elixir, "Identifier", _), do: "String.t()"
140+
defp shape_to_type(:elixir, "Identifier", _), do: "String.t() | Atom.t()"
141141
defp shape_to_type(:erlang, "Identifier", _), do: "string()"
142-
defp shape_to_type(:elixir, "identifier", _), do: "String.t()"
142+
defp shape_to_type(:elixir, "identifier", _), do: "String.t() | Atom.t()"
143143
defp shape_to_type(:erlang, "identifier", _), do: "string()"
144-
defp shape_to_type(:elixir, "XmlString" <> _rest, _), do: "String.t()"
144+
defp shape_to_type(:elixir, "XmlString" <> _rest, _), do: "String.t() | Atom.t()"
145145
defp shape_to_type(:erlang, "XmlString" <> _rest, _), do: "string"
146146
defp shape_to_type(:elixir, "NullablePositiveInteger", _), do: "nil | non_neg_integer()"
147147
defp shape_to_type(:erlang, "NullablePositiveInteger", _), do: "undefined | non_neg_integer()"
@@ -153,7 +153,7 @@ defmodule AWS.CodeGen.Types do
153153
defp shape_to_type(_, %Shape{type: "timestamp"}, _module_name), do: "non_neg_integer()"
154154
defp shape_to_type(_, %Shape{type: "map"}, _module_name), do: "map()"
155155
defp shape_to_type(_, %Shape{type: "blob"}, _module_name), do: "binary()"
156-
defp shape_to_type(:elixir, %Shape{type: "string"}, _module_name), do: "String.t()"
156+
defp shape_to_type(:elixir, %Shape{type: "string"}, _module_name), do: "String.t() | Atom.t()"
157157
defp shape_to_type(:erlang, %Shape{type: "string"}, _module_name), do: "string()"
158158
defp shape_to_type(_, %Shape{type: "integer"}, _module_name), do: "integer()"
159159
defp shape_to_type(_, %Shape{type: "boolean"}, _module_name), do: "boolean()"
@@ -314,9 +314,9 @@ defmodule AWS.CodeGen.Types do
314314
parameters,
315315
fn parameter ->
316316
if not parameter.required do
317-
", String.t() | nil"
317+
", String.t() | Atom.t() | nil"
318318
else
319-
", String.t()"
319+
", String.t() | Atom.t()"
320320
end
321321
end
322322
)

priv/post.ex.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule <%= context.module_name %> do
2525
}
2626
<% end %>
2727
"""
28-
@type <%= if map_size(type_fields) == 0 do "#{type_name}() :: %{}" else "#{type_name}() :: %{String.t => any()}" end %>
28+
@type <%= if map_size(type_fields) == 0 do "#{type_name}() :: %{}" else "#{type_name}() :: %{String.t() | Atom.t() => any()}" end %>
2929
<% end %>
3030

3131
<%= Enum.map(context.actions,

priv/rest.ex.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule <%= context.module_name %> do
2525
}
2626
<% end %>
2727
"""
28-
@type <%= if Enum.empty?(type_fields) do "#{type_name}() :: %{}" else "#{type_name}() :: %{String.t => any()}" end %>
28+
@type <%= if Enum.empty?(type_fields) do "#{type_name}() :: %{}" else "#{type_name}() :: %{String.t() | Atom.t() => any()}" end %>
2929
<% end %>
3030

3131
<%= Enum.map(context.actions,

0 commit comments

Comments
 (0)