Render better errors for ENUM validation

This commit is contained in:
Egor Kislitsyn 2020-05-04 22:33:34 +04:00
parent f070b5569c
commit e55fd530bc
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805

View file

@ -17,6 +17,9 @@ def init(opts), do: opts
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)}