open-api-spex / open_api_spex

Open API Specifications for Elixir Plug applications
Mozilla Public License 2.0
681 stars 177 forks source link

Cast number schema should return float #610

Closed David-Klemenc closed 2 days ago

David-Klemenc commented 1 month ago

OpenApiSpex.Schema.cast and OpenApiSpex.cast_value return different results when casting 1

iex> float_schema = %OpenApiSpex.Schema{type: :number, format: :float}
%OpenApiSpex.Schema%{type: :number, format: :float}
iex> OpenApiSpex.Schema.cast(float_schema, 1, %{})
{:ok, 1.0}
iex> OpenApiSpex.cast_value(1, float_schema)
{:ok, 1}

The correct response should be {:ok, 1.0} for OpenApiSpex.cast_value(1, float_schema)

This is a simlar issue to: #84

mbuhot commented 2 days ago

Fixed in #611, thanks @David-Klemenc