# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.Schemas.BooleanLike do
+ alias OpenApiSpex.Cast
alias OpenApiSpex.Schema
require OpenApiSpex
%Schema{type: :boolean},
%Schema{type: :string},
%Schema{type: :integer}
- ]
+ ],
+ "x-validate": __MODULE__
})
- def after_cast(value, _schmea) do
- {:ok, Pleroma.Web.ControllerHelper.truthy_param?(value)}
+ def cast(%Cast{value: value} = context) do
+ context
+ |> Map.put(:value, Pleroma.Web.ControllerHelper.truthy_param?(value))
+ |> Cast.ok()
end
end