1
0
mirror of https://git.pleroma.social/sjw/pleroma.git synced 2024-11-18 16:17:23 +01:00

Ignore unexpected ENUM values in query string

This commit is contained in:
Egor Kislitsyn 2020-05-04 21:46:25 +04:00
parent bfbff7d826
commit 4b9ab67aa8
No known key found for this signature in database
GPG Key ID: 1B49CB15B71E7805

View File

@ -110,6 +110,10 @@ defmodule Pleroma.Web.ApiSpec.CastAndValidate do
%{reason: :unexpected_field, name: name, path: [name]}, params ->
Map.delete(params, name)
%{reason: :invalid_enum, name: nil, path: path, value: value}, params ->
path = path |> Enum.reverse() |> tl() |> Enum.reverse() |> list_items_to_string()
update_in(params, path, &List.delete(&1, value))
_, params ->
params
end)
@ -118,4 +122,11 @@ defmodule Pleroma.Web.ApiSpec.CastAndValidate do
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type)
end
end
defp list_items_to_string(list) do
Enum.map(list, fn
i when is_atom(i) -> to_string(i)
i -> i
end)
end
end