Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F116164
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/open_api_spex/cast_array.ex b/lib/open_api_spex/cast_array.ex
index ccb45e0..23c0bd6 100644
--- a/lib/open_api_spex/cast_array.ex
+++ b/lib/open_api_spex/cast_array.ex
@@ -1,36 +1,35 @@
defmodule OpenApiSpex.CastArray do
@moduledoc false
alias OpenApiSpex.{Cast, CastContext}
def cast(%{value: []}) do
{:ok, []}
end
def cast(%{value: items} = ctx) when is_list(items) do
results =
items
|> Enum.with_index()
|> Enum.map(fn {item, index} ->
path = [index | ctx.path]
Cast.cast(%{ctx | value: item, schema: ctx.schema.items, path: path})
end)
errors =
Enum.flat_map(results, fn
- {:error, errors} when is_list(errors) -> errors
- {:error, error} -> [error]
+ {:error, errors} -> errors
_ -> []
end)
if errors == [] do
items = Enum.map(results, fn {:ok, item} -> item end)
{:ok, items}
else
{:error, errors}
end
end
def cast(ctx) do
CastContext.error(ctx, {:invalid_type, :array})
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 30, 2:42 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41466
Default Alt Text
(1 KB)
Attached To
Mode
R22 open_api_spex
Attached
Detach File
Event Timeline
Log In to Comment