Skip to content
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
16 changes: 8 additions & 8 deletions lib/aws_codegen/types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ defmodule AWS.CodeGen.Types do
end

# Unfortunately, gotta patch over auto-defining types that already exist in Elixir
defp shape_to_type(:elixir, "String", _), do: "String.t()"
defp shape_to_type(:elixir, "String", _), do: "String.t() | atom()"
defp shape_to_type(:erlang, "String", _), do: "string()"
defp shape_to_type(:elixir, "string", _), do: "String.t()"
defp shape_to_type(:elixir, "string", _), do: "String.t() | atom()"
defp shape_to_type(:erlang, "string", _), do: "string()"
defp shape_to_type(:elixir, "Identifier", _), do: "String.t()"
defp shape_to_type(:elixir, "Identifier", _), do: "String.t() | atom()"
defp shape_to_type(:erlang, "Identifier", _), do: "string()"
defp shape_to_type(:elixir, "identifier", _), do: "String.t()"
defp shape_to_type(:elixir, "identifier", _), do: "String.t() | atom()"
defp shape_to_type(:erlang, "identifier", _), do: "string()"
defp shape_to_type(:elixir, "XmlString" <> _rest, _), do: "String.t()"
defp shape_to_type(:elixir, "XmlString" <> _rest, _), do: "String.t() | atom()"
defp shape_to_type(:erlang, "XmlString" <> _rest, _), do: "string"
defp shape_to_type(:elixir, "NullablePositiveInteger", _), do: "nil | non_neg_integer()"
defp shape_to_type(:erlang, "NullablePositiveInteger", _), do: "undefined | non_neg_integer()"
Expand All @@ -153,7 +153,7 @@ defmodule AWS.CodeGen.Types do
defp shape_to_type(_, %Shape{type: "timestamp"}, _module_name), do: "non_neg_integer()"
defp shape_to_type(_, %Shape{type: "map"}, _module_name), do: "map()"
defp shape_to_type(_, %Shape{type: "blob"}, _module_name), do: "binary()"
defp shape_to_type(:elixir, %Shape{type: "string"}, _module_name), do: "String.t()"
defp shape_to_type(:elixir, %Shape{type: "string"}, _module_name), do: "String.t() | atom()"
defp shape_to_type(:erlang, %Shape{type: "string"}, _module_name), do: "string()"
defp shape_to_type(_, %Shape{type: "integer"}, _module_name), do: "integer()"
defp shape_to_type(_, %Shape{type: "boolean"}, _module_name), do: "boolean()"
Expand Down Expand Up @@ -314,9 +314,9 @@ defmodule AWS.CodeGen.Types do
parameters,
fn parameter ->
if not parameter.required do
", String.t() | nil"
", String.t() | atom() | nil"
else
", String.t()"
", String.t() | atom()"
end
end
)
Expand Down
2 changes: 1 addition & 1 deletion priv/post.ex.eex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule <%= context.module_name %> do
}
<% end %>
"""
@type <%= if map_size(type_fields) == 0 do "#{type_name}() :: %{}" else "#{type_name}() :: %{String.t => any()}" end %>
@type <%= if map_size(type_fields) == 0 do "#{type_name}() :: %{}" else "#{type_name}() :: %{(String.t() | atom()) => any()}" end %>
<% end %>

<%= Enum.map(context.actions,
Expand Down
6 changes: 3 additions & 3 deletions priv/rest.ex.eex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule <%= context.module_name %> do
}
<% end %>
"""
@type <%= if Enum.empty?(type_fields) do "#{type_name}() :: %{}" else "#{type_name}() :: %{String.t => any()}" end %>
@type <%= if Enum.empty?(type_fields) do "#{type_name}() :: %{}" else "#{type_name}() :: %{(String.t() | atom()) => any()}" end %>
<% end %>

<%= Enum.map(context.actions,
Expand Down Expand Up @@ -71,7 +71,7 @@ defmodule <%= context.module_name %> do
@doc """
<%= action.docstring %>
"""<% end %><%= if action.method == "GET" do %>
@spec <%= action.function_name %>(map()<%= if context.module_name == "AWS.ApiGatewayManagementApi" do %>, String.t()<% end %><%= AWS.CodeGen.Types.function_parameter_types(action.method, action, false)%>, list()) :: <%= AWS.CodeGen.Types.return_type(context.language, action)%>
@spec <%= action.function_name %>(map()<%= if context.module_name == "AWS.ApiGatewayManagementApi" do %>, String.t() | atom()<% end %><%= AWS.CodeGen.Types.function_parameter_types(action.method, action, false)%>, list()) :: <%= AWS.CodeGen.Types.return_type(context.language, action)%>
def <%= action.function_name %>(%Client{} = client<%= if context.module_name == "AWS.ApiGatewayManagementApi" do %>, stage<% end %><%= AWS.CodeGen.RestService.function_parameters(action) %>, options \\ []) do
url_path = "<%= if context.module_name == "AWS.ApiGatewayManagementApi" do %>/#{stage}<% end %><%= AWS.CodeGen.RestService.Action.url_path(action) %>"
headers = []<%= for parameter <- action.request_header_parameters do %>
Expand Down Expand Up @@ -115,7 +115,7 @@ defmodule <%= context.module_name %> do
<% end %>

Request.request_rest(client, meta, :get, url_path, query_params, headers, nil, options, <%= inspect(action.success_status_code) %>)<% else %>
@spec <%= action.function_name %>(map()<%= AWS.CodeGen.Types.function_parameter_types(action.method, action, false)%>, <%= if context.module_name == "AWS.ApiGatewayManagementApi" do %> String.t(), <% end %><%= AWS.CodeGen.Types.function_argument_type(context.language, action)%>, list()) :: <%= AWS.CodeGen.Types.return_type(context.language, action)%>
@spec <%= action.function_name %>(map()<%= AWS.CodeGen.Types.function_parameter_types(action.method, action, false)%>, <%= if context.module_name == "AWS.ApiGatewayManagementApi" do %> String.t() | atom(), <% end %><%= AWS.CodeGen.Types.function_argument_type(context.language, action)%>, list()) :: <%= AWS.CodeGen.Types.return_type(context.language, action)%>
def <%= action.function_name %>(%Client{} = client<%= AWS.CodeGen.RestService.function_parameters(action) %>, <%= if context.module_name == "AWS.ApiGatewayManagementApi" do %> stage, <% end %>input, options \\ []) do
url_path = "<%= if context.module_name == "AWS.ApiGatewayManagementApi" do %>/#{stage}<% end %><%= AWS.CodeGen.RestService.Action.url_path(action) %>"<%= if length(action.request_header_parameters) > 0 do %>
{headers, input} =
Expand Down
Loading
Loading