ja_serializer icon indicating copy to clipboard operation
ja_serializer copied to clipboard

Remove PhoenixView in favor of documenting how to integrate.

Open alanpeabody opened this issue 8 years ago • 6 comments

This is in the spirit of explicit over implicit.

Suggested by @nurugger07 in #34.

All view really needs is:

defmodule Example.PostView do
  use Example.Web, :view
  use JaSerializer

  def render(action, %{data: data, conn: conn} = args) when action in ["index.json-api", "show.json-api"] do
    JaSerializer.format(__MODULE__, data, conn, args[:opts] || [])
  end

  attributes [:title, :body]
end

Something would also need to be added to the changeset and error views.

alanpeabody avatar Aug 27 '16 20:08 alanpeabody

Agree to this. I understand how we want to have a plugin that works out of the box. However, explicitly for View, I don't think we need the implicit contextual PhoenixView especially that we will most likely customize the rendering of our data.

This would also allow the project to move independent of framework but only by Plugs.

nmcalabroso avatar Nov 28 '16 13:11 nmcalabroso

I would love to see a PR to the docs/README overhauling and documenting how to use this lib with Phoenix w/o the phoenix view. Once we have that we can deprecate PhoenixView for removal in a (hopefully) soon to come 1.0 release.

alanpeabody avatar Nov 28 '16 14:11 alanpeabody

You also need to explicitly handle render :errors. I am quite happy with the PhoenixView.

pinx avatar Jan 03 '17 15:01 pinx

From the perspective of an Elixir beginner, I'm really happy with PhoenixView and anything it can provide to reduce the amount of boilerplate.

oskarrough avatar Jan 23 '17 22:01 oskarrough

I think removing PhoenixView is a good idea. Recently we want to do I18n for JSON API errors, and we have to build our own EctoErrorSerializer to integrate Gettext. It's actually not hard but lead me to think if we really need the helpers PhoenixView provides. Most of time Serializer.format is enough.

Maybe moving Phoenix integration to another lib like ja-serializer-phoenix is better. People can still use it for seamlessly integration.

I'm also glad to PR a config to use custom Ecto error serializer (maybe even a common behaviour), but if PhoenixView is removed, I think the config will not be necessary.

darkbaby123 avatar Apr 06 '17 02:04 darkbaby123

I think a ja-serializer-phoenix lib is a good idea. :+1:

alanpeabody avatar Apr 06 '17 12:04 alanpeabody