-
Notifications
You must be signed in to change notification settings - Fork 205
Closed
Labels
Description
From #42
enums validation: cast does not "atomify" keys in maps of enum payloads. In other words, the following code does not crash:
schema = %Schema{enum: [%{id: 42}]}
spec = ...
# string keys
{:ok, data} = OpenApiSpex.cast(spec, schema, %{"id" => 42})
{:error, _} = OpenApiSpex.validate(spec, schema, data)
# atom keys
{:ok, data} = OpenApiSpex.cast(spec, schema, %{id: 42})
:ok = OpenApiSpex.validate(spec, schema, data)I think it would be very dangerous (OOM) to atomify enum keys anyway!
My current workaround is to specify enum schemas with string keys instead, which can be easily missed by anyone.
So how about throwing an error when creating a schema that has atom keys in enum: ...?