From: Egor Kislitsyn Date: Mon, 4 May 2020 18:33:34 +0000 (+0400) Subject: Render better errors for ENUM validation X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=e55fd530bc9a6ab42e475efe689e239963906928;p=akkoma Render better errors for ENUM validation --- diff --git a/lib/pleroma/web/api_spec/render_error.ex b/lib/pleroma/web/api_spec/render_error.ex index b5877ca9c..d476b8ef3 100644 --- a/lib/pleroma/web/api_spec/render_error.ex +++ b/lib/pleroma/web/api_spec/render_error.ex @@ -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)}