forked from AkkomaGang/akkoma
Ignore unexpected ENUM values in query string
This commit is contained in:
parent
bfbff7d826
commit
4b9ab67aa8
1 changed files with 11 additions and 0 deletions
|
@ -110,6 +110,10 @@ defp cast_and_validate(spec, operation, conn, content_type) do
|
||||||
%{reason: :unexpected_field, name: name, path: [name]}, params ->
|
%{reason: :unexpected_field, name: name, path: [name]}, params ->
|
||||||
Map.delete(params, name)
|
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 ->
|
||||||
params
|
params
|
||||||
end)
|
end)
|
||||||
|
@ -118,4 +122,11 @@ defp cast_and_validate(spec, operation, conn, content_type) do
|
||||||
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type)
|
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue