I updated my app to phx 1.4 Every thing is working fine but when i run test cases. It gives me warning for almost every test case.
warning: Elixir.Phoenix.Controller.render/4 with a view is deprecated, see the documentation for render/3
for an alternative
(phoenix) lib/phoenix/controller.ex:719: Phoenix.Controller.render/4
(app) web/router.ex:8: App.Router.token_auth/2
(app) web/router.ex:1: App.Router.__pipe_through2__/1
(phoenix) lib/phoenix/router.ex:270: Phoenix.Router.__call__/1
(app) lib/app/endpoint.ex:1: App.Endpoint.plug_builder_call/2
(app) lib/haitracker/endpoint.ex:1: App.Endpoint.call/2
I didn’t see any changelog regarding to the render function.
warning: Elixir.Phoenix.Controller.render/4 with a view is deprecated, see the documentation for render/3 for an alternative
(phoenix 1.6.5) lib/phoenix/controller.ex:758: Phoenix.Controller.render/4
I’m getting same warnings and I checked my code I couldn’t find any functions with arity render/4 all render() functions with 3 arguments.
Sample code below:
@spec create(Plug.Conn.t(), map) :: Plug.Conn.t()
def create(conn, params) do
current_user = conn.assigns[:current_user]
with {:ok, %Asset{} = asset} <- Document.create_asset(current_user, params) do
render(conn, :asset, asset: asset)
end
end
@doc """
Asset index.
"""
swagger_path :index do
get("/assets")
summary("Asset index")
description("API to get the list of all assets created so far under an organisation")
parameter(:page, :query, :string, "Page number")
response(200, "Ok", Schema.ref(:AssetsIndex))
response(401, "Unauthorized", Schema.ref(:Error))
end
@spec index(Plug.Conn.t(), map) :: Plug.Conn.t()
def index(conn, params) do
current_user = conn.assigns[:current_user]
with %{
entries: assets,
page_number: page_number,
total_pages: total_pages,
total_entries: total_entries
} <- Document.asset_index(current_user, params) do
render(conn, "index.json",
assets: assets,
page_number: page_number,
total_pages: total_pages,
total_entries: total_entries
)
end
end
Note: project serving only JSON API’s and I’m upgrading from Phoenix 1.4.14 to 1.6.5
How can I fix these issues?
How to find out what triggers these warnings?