Render better errors for ENUM validation
authorEgor Kislitsyn <egor@kislitsyn.com>
Mon, 4 May 2020 18:33:34 +0000 (22:33 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Mon, 4 May 2020 18:33:34 +0000 (22:33 +0400)
lib/pleroma/web/api_spec/render_error.ex

index b5877ca9c3b70a540be5d765eb13b5ec634648b1..d476b8ef3a237b889031e401c60d22969e057b3c 100644 (file)
@@ -17,6 +17,9 @@ defmodule Pleroma.Web.ApiSpec.RenderError do
   def call(conn, errors) do
     errors =
       Enum.map(errors, fn
+        %{name: nil, reason: :invalid_enum} = err ->
+          %OpenApiSpex.Cast.Error{err | name: err.value}
+
         %{name: nil} = err ->
           %OpenApiSpex.Cast.Error{err | name: List.last(err.path)}