JSONAPI Elixir

A project that will render your data models into JSONAPI Documents.

Currently in beta status.

JSONAPI Support

JSONAPI Elixir TODO

How to use

Simply add use JSONAPI.PhoenixView either to the top of your view, or to the web.ex view section and add the proper functions to your view like so.

defmodule UserView do
  use App.Web, :view
  use JSONAPI.PhoenixView

  def type, do: "user"

  def attributes(model) do
    Map.take(model, [:username, :created_at])
  end

  def relationships() do
    %{
      image: %{
        view: ImageView
      },
      posts: %{
        view: PostView
        optional: true
      }
    }
  end
  
  def url_func() do
    &user_url/3
  end
end

is an example of a basic view. You can now call render normally in your phoenix application.

Philosophy

Other